Order types in trading specify when a broker should attempt execution and any price constraints. A market order requests execution at available market prices; it can be rejected, and its fill can differ from the displayed quote. A limit sets a maximum buy price or minimum sell price. A stop activates after a trigger level is reached, while a stop-limit activates a limit order. MetaTrader 5 (MT5) defines six pending types; availability and execution depend on the symbol and broker.[1]
Part of the trading mechanics library, this guide uses MT5's own MQL5 names and shows which of these orders a PineConnector alert can request.

Order types at a glance
The trigger rules below come from MetaQuotes' Basic Principles page, for symbols that are not exchange-traded.[1] The fill-price rules come from its Executing Trades page.[2]
Scroll horizontally to read every column.
| Order type (where it sits) | Triggers when | Fill price |
|---|---|---|
| Market buy (current price) | Immediate request, subject to broker checks | Generally the Ask |
| Market sell (current price) | Immediate request, subject to broker checks | Generally the Bid |
| Buy limit (below the Ask) | Ask ≤ order price | Order price or better |
| Sell limit (above the Bid) | Bid ≥ order price | Order price or better |
| Buy stop (above the Ask) | Ask ≥ order price | Order price or worse |
| Sell stop (below the Bid) | Bid ≤ order price | Order price or worse |
| Buy stop limit (stop above the Ask, limit below the stop) | Ask reaches the stop: a buy limit is placed | Limit price or better, if it fills |
| Sell stop limit (stop below the Bid, limit above the stop) | Bid reaches the stop: a sell limit is placed | Limit price or better, if it fills |
In MQL5 the same eight are ORDER_TYPE_BUY, ORDER_TYPE_SELL, ORDER_TYPE_BUY_LIMIT, ORDER_TYPE_SELL_LIMIT, ORDER_TYPE_BUY_STOP, ORDER_TYPE_SELL_STOP, ORDER_TYPE_BUY_STOP_LIMIT and ORDER_TYPE_SELL_STOP_LIMIT, all listed in ENUM_ORDER_TYPE.[3]
Which price triggers each order type?
MetaQuotes says a security is generally bought at the Ask and sold at the Bid. Pending orders follow the same split: buy orders are compared with the Ask, and sell orders with the Bid.[1]
Buy limit: Ask ≤ order price · Buy stop: Ask ≥ order price · Sell limit: Bid ≥ order price · Sell stop: Bid ≤ order price
"Order price" is the pending order's Price field. A limit sits where you would rather trade, below the Ask to buy or above the Bid to sell. A stop sits on the other side and triggers when price moves through it.[1] The gap between the two quotes is covered in bid, ask and spread explained.

- Charts show the Bid. MT5 forms bars from Bid prices, or from Last prices when depth of market is available. The Ask is not drawn unless you enable "Show Ask price line".[4] A buy limit therefore needs the Bid candle to pass its line by the spread, and a buy stop triggers before the Bid candle reaches its line.
- Exchange-traded symbols use Last. With the Exchange Stocks, Exchange Futures and Futures Forts calculation modes, pending orders usually trigger on the Last price. The resulting trade still executes at the Ask or Bid.[1]
- Stops switch sides after the fill. A long position's stop loss and take profit are checked against the Bid, and a short position's against the Ask.[1] A buy limit fills on the Ask, but its stop loss then watches the Bid.
Worked example: four pending orders around one EURUSD quote
Illustrative example, not a recommendation. EURUSD quotes Bid 1.10000 and Ask 1.10010, a spread of 0.00010, or 1.0 pip on a five-digit quote. Four pending orders sit at 1.10200 and 1.09800, and the spread stays at 1.0 pip.
- Buy limit 1.09800 triggers when Ask ≤ 1.09800. The Ask must fall 21 pips: 1.10010 − 1.09800 = 0.00210. The Bid is then 1.09790, one pip below the line.
- Sell stop 1.09800 triggers when Bid ≤ 1.09800. The Bid must fall 20 pips: 1.10000 − 1.09800 = 0.00200.
- Buy stop 1.10200 triggers when Ask ≥ 1.10200. The Ask must rise 19 pips: 1.10200 − 1.10010 = 0.00190. The Bid is then 1.10190, one pip short of the line.
- Sell limit 1.10200 triggers when Bid ≥ 1.10200. The Bid must rise 20 pips: 1.10200 − 1.10000 = 0.00200.
The buy limit and the sell stop share a price but not a trigger. If the spread is 3.0 pips when price reaches 1.09800, the buy limit needs a Bid of 1.09800 − 0.00030 = 1.09770 or lower. A Bid-built candle can dip through 1.09800 while the buy limit stays unfilled. A long position's stop loss at 1.09800 triggers on the Bid, so it fires with the sell stop.[1]
Market, limit or stop: what does each order give up?
The SEC's investor guide describes a market order as one to buy or sell immediately, generally at or near the bid for a sell or the ask for a buy.[5] Order types place different conditions on activation and execution. None bypasses the broker’s checks, and their price constraints and slippage risks differ.
- Market order: a request for prompt execution. MT5 checks the request before execution and may reject it. The fill price depends on the symbol's execution mode. In Market Execution, sending the order means advance consent to the broker's price; in Instant Execution, the broker can requote.[1] See slippage and requotes and MT5 filling policies.
- Limit order: the price is known, the fill is not. MetaQuotes says limit orders execute at the specified price or better, so no slippage occurs, but the broker may reject one if price moves too far the other way.[2]
- Stop order: the trigger is known, the price is not. A triggered stop order sends the broker a market order request, filled at the specified price or worse.[2]
- Stop-limit order: a stop that places a limit. MetaQuotes describes it as a way to set a stop order and limit the slippage.[2] The SEC's bulletin adds the cost: the limit price may prevent the order from being executed.[6]
How does a stop-limit order work in MT5?
A buy stop limit is a stop order that places a buy limit. When the Ask reaches the stop level in the Price field, MT5 places a buy limit at the Stop Limit price. The stop sits above the current Ask and the Stop Limit price below the stop. A sell stop limit mirrors this on the Bid.[1] MQL5 stores the second price as ORDER_PRICE_STOPLIMIT.[3]

Illustrative example, not a recommendation. With the Ask at 1.10010, a buy stop limit has a stop of 1.10200 and a Stop Limit price of 1.10150. When the Ask reaches 1.10200, a buy limit at 1.10150 appears. It fills only if the Ask comes back to 1.10150 or lower, 5 pips below the stop. A plain buy stop at 1.10200 would request a market buy at that moment instead.
Conventions differ outside MT5. The SEC's stock example is a sell stop at $3.00 with a limit of $2.50, below the stop rather than above it.[6] Read your platform's own description before setting both prices.
How long does a pending order stay open?
Every MT5 pending order has an expiry, chosen in the order window's Expiration field.[2] MQL5 names the options in ENUM_ORDER_TYPE_TIME.[3]
-
Good Till Canceled (GTC),
ORDER_TIME_GTC: in the queue until it is removed. -
Today,
ORDER_TIME_DAY: valid only during the current trading day. -
Specified,
ORDER_TIME_SPECIFIED: active until the date and time in the Expiration date field. -
Specified day,
ORDER_TIME_SPECIFIED_DAY: valid through a chosen day. Outside a session, it expires at the nearest trading time.
The broker decides which options each symbol accepts. The specification's Expiration field lists them, and MQL5 reads the same flags as SYMBOL_EXPIRATION_MODE.[7][8] MQL5's return code for a bad expiry is 10022, invalid order expiration date in the request.[9] An order that runs out moves to history as Expired.[1]
Good Till Canceled can still end with the trading day. For GTC symbols, SYMBOL_ORDER_GTC_MODE says whether pending orders and stop levels last until cancelled, are all deleted at day end, or whether only pending orders are deleted.[8] The specified-day cut-off is also worded two ways: 23:59:59 of that day in the MQL5 Reference, 00:00 of the specified day in the order-window help.[3][2] Check a real order's expiry on demo.
Where do you check which order types a symbol allows?
-
Specification window. In Market Watch, right-click the exact broker symbol and choose Specification. Its Orders field lists the allowed types, from market to stop-limit, and its Expiration field the allowed expiry types.[7] MQL5 reads the order list as
SYMBOL_ORDER_MODE.[8] - Stops level. The same window gives the channel, in points from the current price, inside which stops, targets and pending orders cannot be placed.[7] See stops level and freeze level in MT5.
- Chart menu. Right-clicking above the current price offers Sell Limit and Buy Stop; below it, Buy Limit and Sell Stop.[2]
- Trade and History tabs. Untriggered pending orders show on the Trade tab. Final states such as Filled, Canceled, Rejected or Expired show on the History tab.[1]
Field names follow MetaQuotes' help as of 25 September 2026.
Which order types can PineConnector send?
In a PineConnector alert message, the command field chooses the order type. As of 25 September 2026, the PineConnector syntax reference documents the following.[10][11]
-
Market buy or sell:
buyorsell, with one volume method.[10] -
Buy limit, buy stop, sell limit, sell stop:
buylimit,buystop,selllimitandsellstop. Each needs one entry method:entry_price=,entry_pips=orentry_pct=.[11] -
Cancel pending orders:
cancellongorcancelshortcancels the symbol's buy (or sell) stops and limits, not open positions.[12] -
Cancel, then place a new pending order:
cancellongbuystop,cancellongbuylimit,cancelshortsellstopandcancelshortselllimit. Check both halves separately.[12] -
Change a pending order's stop loss or take profit:
newsltpbuystop,newsltpbuylimit,newsltpsellstopandnewsltpselllimitchange the targets, not the entry.[12] - Buy stop limit or sell stop limit: not documented as PineConnector commands. Confirm current support before choosing an integration route.
- An expiry such as GTC, Today or Specified: not documented as a message parameter. Confirm the supported broker and EA configuration before attempting this route. The error guide lists an Invalid expiration message.[13]
The docs say buy and sell are market commands, not substitutes for pending commands.[11] A pending entry in pips or percent starts from the market reference when the request arrives, and its stop loss and take profit start from the pending entry. The docs' examples omit the bid/ask spread and say to check the receiving account for the actual quote side.[14]
Illustrative template for a demo account, not a live-trade instruction. In the TradingView alert's Message field, replacing LicenseID with the ID for a verified demo setup requests this example's buy limit. Use your own broker symbol, size and rules after checking their units and supported settings:
LicenseID,buylimit,EURUSD,vol_lots=0.01,entry_price=1.09800,sl_pips=20,tp_pips=40
With one PineConnector pip equal to 0.00010 here, the requested levels are entry 1.09800, stop loss 1.09800 − 20 × 0.00010 = 1.09600 and take profit 1.09800 + 40 × 0.00010 = 1.10200.[11] An exact entry price passes through unchanged, so it must sit on the correct side of the broker's quote and meet its tick size and minimum distance.[15] Use your broker's exact symbol.
Where does a pending order live: TradingView or the broker?
-
Simulated in TradingView. A Pine Script v6 strategy creates a limit or stop order by passing a price to the
limitorstopparameter ofstrategy.entry()orstrategy.order(); passing both creates a stop-limit.[16] By default, the broker emulator fills it using chart data, and order-fill alerts fire immediately.[16] If that alert's message uses thebuycommand, it requests a market entry,[10] so any resulting MT5 deal is priced by the broker when it executes, not at the simulated limit price.[1] See strategy.entry() and strategy.exit() in Pine Script. - Held at the broker. The alert sends a pending command, and the broker checks the order against its own Bid and Ask. MetaQuotes says the broker performs a pending order even if the platform is closed.[2] The chart's simulated order and the broker's order can then fill at different times, or only one may fill. Read why TradingView prices differ from your broker's.
The emulator also treats any price within a bar's range as able to fill a pending order. When price gaps past the order between bars, it fills at the next bar's open.[16] In both designs, alert, webhook delivery, PineConnector processing, the EA's request and broker acceptance are separate stages. An accepted pending order becomes a deal only when it triggers and executes.[1]
What goes wrong with pending orders?
- Wrong side of the market. A buy limit belongs below the Ask and a buy stop above it. In Exchange execution mode MT5 does not verify a limit price, so a buy limit above the Ask triggers almost at once.[1] PineConnector's error guide lists the pending entry's direction and distance among the checks for Invalid price.[13]
- Too close to the price. A pending price inside the Stops level channel gets an "Invalid Stops" reply and is not accepted.[7]
- Type or expiry not allowed. PineConnector's error guide pairs Invalid request with the broker's supported order type, and Invalid expiration with its supported expiration settings. It notes that older EA guidance mentions Broker Set C, and to confirm version support first.[13]
- Rejected at activation. If a triggered order's market operation cannot execute, for example with too little free margin, MT5 cancels it and records it as Rejected.[1]
- Gaps. A stop order fills at its price or worse, so a gap through the level can fill well beyond it.[2] See weekend gaps and the market open.
- Stops wait for the fill. A stop loss or take profit on a pending order passes to the position it opens and triggers only for open positions.[2]
- Orders outlive the alert. PineConnector's FAQ says cancelling a subscription or stopping a hosted terminal does not close broker positions; review open positions and pending orders with the broker.[17] The EA's Maximum Open Positions setting does not restrict pending orders, so later fills can exceed it.[18]
Frequently asked questions
What is the difference between a market order and a limit order?
A market order requests execution at available market prices, subject to broker checks. It can be rejected, and its fill price can differ from the displayed quote. A limit order sets a price or better: a buy limit fills only at or below its price, a sell limit at or above it. MetaQuotes' MT5 help says limit orders fill at their price or better, with no slippage, but they may never fill.
What is the difference between a buy stop and a buy limit?
Both are pending buy orders in MetaTrader 5, placed on opposite sides of the market. A buy limit sits below the current Ask and triggers when the Ask falls to its price or lower, filling at that price or better. A buy stop sits above the Ask and triggers when the Ask rises to its price or higher, filling at that price or worse.
What is a stop-limit order?
A stop-limit order combines two prices. When the market reaches the stop price, a limit order is placed at the limit price, and it fills only at that price or better. In MetaTrader 5, a buy stop limit's stop sits above the Ask with its limit below the stop. The limit caps the fill price, but the order may not fill at all.
How do pending orders work in MT5?
A pending order in MetaTrader 5 is an instruction to buy or sell later under preset conditions. MT5 offers six types: buy limit, buy stop, sell limit, sell stop, buy stop limit and sell stop limit. The broker holds the order and performs it even when the platform is closed. Its expiry can be Good Till Canceled, Today, a specified time or a specified day.
Can PineConnector send pending orders?
Yes. As of 25 September 2026, PineConnector's syntax reference documents four pending commands, buylimit, buystop, selllimit and sellstop, each with an entry set by entry_price=, entry_pips= or entry_pct=. It also documents cancelling pending orders and changing their stop loss and take profit. No stop-limit command or expiry parameter is documented. Confirm current support before attempting either through PineConnector.
Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account.
Related reading
- How forex trading works: orders, lots, margin and costs in MT5
- Bid, ask and spread explained
- Stops level and freeze level in MT5
- MT5 filling policies: FOK, IOC, Return and BOC
- Slippage and requotes: why fills differ from the requested price
Sources
- MetaQuotes – MetaTrader 5 Help: Basic Principles, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Executing Trades, accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Order Properties, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Chart Settings, accessed 25 September 2026.
- U.S. Securities and Exchange Commission (Investor.gov) – Types of Orders, accessed 25 September 2026.
- U.S. Securities and Exchange Commission (Investor.gov) – Stop, Stop-Limit, and Trailing Stop Orders: Investor Bulletin, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Market Watch and symbol specification, accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Symbol Properties, accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Trade Server Return Codes, accessed 25 September 2026.
- PineConnector – Syntax: market commands, accessed 25 September 2026.
- PineConnector – Syntax: pending commands, accessed 25 September 2026.
- PineConnector – Syntax: close, cancel and modify, accessed 25 September 2026.
- PineConnector – EA errors: match the message beside 4756, accessed 25 September 2026.
- PineConnector – Syntax: pending reference price, accessed 25 September 2026.
- PineConnector – Syntax: entry_price=, accessed 25 September 2026.
- TradingView – Pine Script v6 User Manual: Strategies, accessed 25 September 2026.
- PineConnector – Frequently asked questions: cancelling a subscription, accessed 25 September 2026.
- PineConnector – EA settings reference: Maximum Open Positions, accessed 25 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.