STOP
STOP in ProBacktest and ProOrder is the stop order type for entries and exits, placing a pending order that fills once price crosses a level. Examples included.
Syntax
[BUY|SELLSHORT] quantity unit AT price STOPHow it works
STOP follows a price in a BUY or SELLSHORT order to make it a pending stop order rather than an immediate one. A buy stop is placed above the current price and triggers when price trades up through the level, the usual form for breakout entries. A sell stop is placed below the current price and triggers when price trades down through the level.
STOP is one of the three order-type keywords, alongside MARKET for immediate execution and LIMIT for a pending order that waits for a better price. A pending stop that does not fill on the next bar is cancelled, so a persistent stop entry must be resubmitted each bar while the setup holds.
Do not confuse this order type with SET STOP LOSS, which sets a stop-loss level on a position already open. This page documents the STOP entry and exit order type. For the separate pending-stop protective mechanism see STOP (pending).
Examples
Example 1, Breakout entry with a buy stop (ProBacktest)
DEFPARAM CumulateOrders = false
// Buy a break of the 20-bar high
entryLevel = Highest[20](high)
IF NOT OnMarket THEN
BUY 1 CONTRACT AT entryLevel STOP
ENDIFThe pending stop rests above the market and fills only if price trades up through the previous 20-bar high, so the entry follows a confirmed breakout.
Example 2, Short breakdown with a sell stop (ProOrder)
DEFPARAM CumulateOrders = false
// Sell short a break below the 20-bar low
level = Lowest[20](low)
IF NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT level STOP
ENDIFThe sell stop sits below the market and triggers when price breaks the 20-bar low, entering short on the downside break.
Example 3, Stop entry with a protective stop loss (ProOrder)
DEFPARAM CumulateOrders = false
// Enter on a breakout, then protect the position
entryLevel = Highest[20](high)
IF NOT LongOnMarket THEN
BUY 1 CONTRACT AT entryLevel STOP
ENDIF
SET STOP LOSS 30Here the STOP order type places the entry, while SET STOP LOSS attaches a 30-point protective stop to the resulting position. The two uses of the word "stop" are different mechanisms.
Common errors and gotchas
- Order type versus stop loss.
AT price STOPplaces a pending entry or exit order.SET STOP LOSSprotects an open position. They are separate and easy to mix up. - Level on the wrong side. A buy stop must sit above the current price and a sell stop below it. A stop placed on the wrong side of the market is not a valid stop order.
- Pending orders expire after one bar. A
STOPorder that does not fill on the next bar is cancelled. Resubmit it each bar while the setup remains valid. - Stop versus limit.
STOPbuys as price rises through a level,LIMITbuys as price falls to a better level. Swapping them reverses the entry logic.
Related instructions
MARKET, immediate execution at the current price.LIMIT, pending order at a stated price or better.BUY, opens a long position, which a stop order can trigger.SELLSHORT, opens a short position, which a stop order can trigger.SELL,EXITSHORT, close positions and can also use a stop level.SET, attaches a protective stop or target to an open position.TARGET, the profit-target counterpart of a protective stop.
