An order is an instruction to the broker to open or close a position. There are two families. A market order executes now, at the best price available. A pending order waits until the market reaches a price you specify, then executes.
Market orders
A market order says "buy now" or "sell now". It is filled at the current ask or bid, or, in a fast market, at the next available price, which may be slightly worse. That difference is slippage. Most MetaTrader 5 brokers use market execution, which means the order is filled at whatever price the broker can obtain and requotes are not offered. The alternative, instant execution, fills at the price you clicked or not at all, and returns a requote if the price has moved.
Pending orders
A buy limit is an order to buy below the current price, placed when you expect a pullback before a rise. A sell limit is an order to sell above the current price. Limit orders are used to enter at a better price than the current one, and they fill only if the market comes to them.
A buy stop is an order to buy above the current price, placed when you want to enter only once the market has broken through a level. A sell stop is an order to sell below the current price. Stop orders are used to enter on a breakout, and once triggered they become market orders, filled at the next available price.
MetaTrader 5 also offers a buy stop limit and a sell stop limit, which place a limit order when a trigger price is reached. They are rarely used in retail trading.
Every pending order can carry an expiry time, and one that has not filled by then is cancelled.
Fills and the differences between them
A limit order never fills at a worse price than you set. Its risk is that it does not fill at all. Price can touch the level and reverse, or come within a fraction of it and never reach the exact figure, and the trade you wanted does not exist.
A stop order almost always fills once triggered. Its risk is the price. In a fast market or across a gap, a stop order set at 1.2750 may fill at 1.2760, and the slippage is a real cost.
Gold is at $2,400 and you expect a move higher only if it clears $2,410. You place a buy stop at $2,410.50. Two hours later a US inflation figure sends gold from $2,406 to $2,418 in a few seconds. Your order triggers at $2,410.50 and fills at $2,414.20, because that was the first price available. The trade has started $3.70 an ounce, or $370 on one lot, behind where you intended.
Had you used a buy limit at $2,398 instead, expecting a dip first, the dip never came and the order sat unfilled while gold rallied.
Most well-designed EAs place market orders at the open of a new bar, having made their decision on the closed bar before it. This is the simplest and most reproducible approach: the fill is close to the open price, the backtest can model it honestly, and there is no dependence on a pending order being touched. Some breakout systems use stop orders placed at a level, which is reasonable, provided the backtest accounts for slippage on the fill.
The approach to be wary of is an EA that relies on limit orders to enter at better prices. In a backtest, every limit order that price touched is assumed filled. In live trading many of them are not, and those that are not filled tend to be the best trades, the ones where price barely dipped before running. A backtest built on limit fills flatters the strategy in a way that live trading exposes.