STOP (pending)
STOP (pending) places a pending stop order in ProBacktest and ProOrder, entering or exiting when price reaches the stop level, as in BUY 1 LOT AT x STOP.
Syntax
BUY quantity CONTRACT AT price STOP
SELLSHORT quantity CONTRACT AT price STOP
SELL AT price STOP
EXITSHORT AT price STOPParameters
| Name | Type | Default | Description |
|---|---|---|---|
quantity | integer | none | Number of contracts, lots, or shares for entry orders. Omitted on SELL and EXITSHORT, which close the whole position. |
price | numeric | none | The trigger level. A buy stop sits above the current price, a sell stop below it. |
How it works
An AT price STOP order stays inactive until the market trades at or through the trigger level. A buy stop placed above the current price fills when price rises to the level, which makes it suitable for breakout entries. A sell stop placed below the current price fills when price falls to the level, which makes it suitable for protective exits or short breakout entries.
The order is pending, not persistent. It remains valid only until the close of the next bar. If the level is not reached, the order lapses and must be issued again on the following bar for the setup to remain live. Strategies therefore usually place the order inside a condition that stays true while the setup is valid.
Disambiguation: ProBuilder has two distinct uses of the word STOP. This page covers the pending-order form, BUY ... AT price STOP, which creates an order at an absolute price level. The separate money-management keyword documented at STOP configures a stop loss as a distance from the entry price, for example SET STOP LOSS 20. The two can coexist in one strategy, but they are compiled and managed differently.
Examples
Example 1, MACD signal with a buy stop above the close (ProOrder)
myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0
IF long THEN
// Enter only if price confirms by rising 10 points above the signal close
BUY 1 LOT AT close + 10 STOP
ENDIFThe MACD crossover arms the setup, but the position opens only if price then climbs 10 points above the signal bar close. Without that confirmation move, the pending order expires.
Example 2, Sell stop as a fixed protective exit (ProBacktest)
IF longonmarket THEN
// Re-place the exit order on every bar, 20 points below entry
SELL AT tradeprice - 20 * pointsize STOP
ENDIFWhile a long position is open, a sell stop sits 20 points below the entry price. Because pending orders lapse after one bar, the order is re-issued on every bar the position remains open.
Example 3, Breakout above the 20-bar high (ProOrder)
periodHigh = highest[20](high)
IF NOT onmarket THEN
// Buy stop one tick above the recent high
BUY 1 CONTRACT AT periodHigh + ticksize STOP
ENDIFA classic breakout entry. The buy stop tracks the rolling 20-bar high and fills only if price breaks above it.
Common errors and gotchas
- One-bar lifetime. A pending stop order is valid until the end of the next bar only. Strategies that place the order once and assume it persists silently lose the setup. Re-issue the order on every bar while the condition holds.
- Trigger on the wrong side of price. A buy stop must be above the current price and a sell stop below it. An order placed on the wrong side is treated as immediately marketable or rejected, which rarely matches the intended logic.
- Confusing the two STOP keywords.
BUY 1 CONTRACT AT 7500 STOPis an entry order at an absolute level.SET STOP LOSS 20is position protection at a relative distance. Mixing up the syntaxes is a frequent compile-error source, see theSTOPpage for the money-management form. - Backtest fill optimism. ProBacktest fills stop orders exactly at the trigger level. Live execution through ProOrder can slip past the level in fast markets, so live results tend to be slightly worse than the backtest for stop entries.
Related instructions
STOP, the money-management stop loss keyword used inSET STOP LOSS.LIMIT, pending order that fills at a favorable price instead of a breakout level.BUY, opens or adds to a long position.SELLSHORT, opens or adds to a short position.SELL, closes a long position.EXITSHORT, closes a short position.MARKET, immediate execution at the current price.TARGET, take-profit configuration for an open position.LongTriggered, true on the bar where a pending long order was filled.ShortTriggered, true on the bar where a pending short order was filled.
