You should have used a STOP MARKET buy order rather than a LIMIT buy order.
These other people saying you should have used a STOP LIMIT order are dead wrong. If the stock had risen to 24 your stop would have been triggered, but the limit would have meant you weren't willing to pay more than 24. If the stock moved quickly your order would not have been executed, since it was moving above 24.
Here's a quick rundown of the different kinds of orders.
1. Market order
A market order will execute a trade for you at the best current price. For example, the last trade on XYZ was 25.10, and the current bid (the price someone is willing to pay to buy) is 25.07, and the current ask (the price someone is willing to accept to sell) is 25.13. If you place a market order to BUY you will pay 25.13, which was the best available price offered. If you place a market order to SELL, or SELL SHORT you will get the 25.07 price, which was the best available offer made for stock.
2. Limit order
Using the same XYZ example, let's say you want to buy the stock, but the highest price you are willing to pay is 24.50. You can place a limit order to buy at 24.50, and your order will go on a list of all the current bids. You have become a bidder. Since there are other bidders willing to buy at a price above yours, your order will be lower on the list. But if the stock trades down to 24.50, the other bids will be executed (or canceled by the bidders themselves) and yours will be executed at 24.50 or better (lower). Sellers of stock (or short sellers) would have the reverse situation (e.g. a limit order to sell at 26 would be executed at 26 or higher, if the stock traded up to that level).
3. Stop order
A stop order is like a limit order in that it only becomes active when a specified price is reached. But it's very different in other ways. A stop order becomes a MARKET order once the specified price is reached. This is what you wanted to do with your trade. You wanted to buy the stock if it reached 24, so a stop buy order would have been the way to do it (although in your case it wouldn't have been executed since the stock never reached that level, but that was what you wanted to be sure of, so it would have been the correct move). In the XYZ example a stop buy order could be placed at 26, and if the stock rises to 26 the order will be executed at the best available price (the bid), which will be fairly close to 26.
Your mistake was using a limit order instead of a stop order. The limit order said you were willing to buy the stock at the best (lowest) available price BELOW 24. Since the stock was already trading well below that level, your order was executed immediately, at the current ask, which was 22.
Hope that all makes sense. Don't feel too bad, I made the same mistake starting out.