You are talking about "day trading" or "revoling trades". Most brokers allow you to day trade (buy a stock and then sell the same day or sell a stock and buy back in the same day) 3 or 4 times in a 5 day trading period before classifying you as a "pattern day trader" and resticting your account.
If you don't go over 4 trades in 5 days, and wait for a week, you can do it all over again and not have to worry about restictions. In the case of TDA, they will warn you when you do this and tell you how many you have in a 5 day period. But they are lagged a bit so it might take them a day or two to report your day trade.