PLOSS
PLOSS sets a stop loss a fixed number of points from the average position price in ProBacktest and ProOrder, written as SET STOP PLOSS x in a strategy.
Syntax
SET STOP PLOSS xParameters
| Name | Type | Default | Description |
|---|---|---|---|
x | integer or numeric expression | required | Distance in points between the average position price and the stop level. |
How it works
When the instruction executes, the strategy registers a protective stop at x points on the losing side of the average position price, below the entry for a long and above it for a short. If price reaches that level, the position closes at market.
The distance is anchored to POSITIONPRICE, the average entry price of the whole position, not to the price of the latest order. When the strategy adds contracts to an existing position, the average moves and the stop level moves with it on the next evaluation.
A SET STOP command stays active until it is replaced. It does not need to be repeated on every bar, although passing a variable as x and re-executing the line lets the distance adapt to changing conditions. All stop variants share one internal stop slot, so calling SET STOP PLOSS after SET STOP %LOSS, SET STOP $LOSS, or a trailing variant simply overwrites the previous setting.
Examples
Example 1, MACD entry with a 50-point stop (ProOrder)
myMACD = MACD[12,26,9](close)
long = myMACD CROSSES OVER 0
IF NOT LongOnMarket AND long THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Stop loss 50 points from the average position price
SET STOP PLOSS 50A long opens when the MACD crosses above zero, and the position is protected by a stop 50 points below the average entry price. This is the reference example from the source documentation with rewritten comments.
Example 2, Point-based stop on a short position (ProBacktest)
short = close CROSSES UNDER average[100](close)
IF NOT shortonmarket AND short THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Stop 30 points above the average short entry price
SET STOP PLOSS 30For a short position the same instruction places the stop on the opposite side, 30 points above the average entry, closing the trade if price rallies that far.
Example 3, Volatility-scaled stop distance (ProOrder)
// Convert an ATR distance in price units into whole points
atr = AverageTrueRange[14](close)
stopPoints = max(10, round((2 * atr) / pointsize))
IF NOT onmarket AND close > highest[20](high[1]) THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
SET STOP PLOSS stopPointsThe stop distance follows volatility, two ATRs converted into points with a 10-point floor, so quiet markets get tight stops and volatile markets get room to breathe.
Common errors and gotchas
- Anchored to the average, not the last fill. After pyramiding or averaging down, the stop is measured from the new POSITIONPRICE. A stop that looked safe relative to the first entry can sit much closer to, or further from, the market than expected.
- One stop slot.
PLOSS,%LOSS,$LOSS,BREAKEVEN, and the trailing variants all write to the same internal stop. Only the most recentSET STOPcall is active, so alternating variants per bar causes erratic exits. - Points are not cash or percent.
xis a point count. UseSET STOP %LOSSfor a percentage distance andSET STOP $LOSSfor a cash amount. Passing a cash figure to PLOSS on an instrument with a small point size produces an absurdly wide stop. - Ideal fills in backtests. ProBacktest fills the stop exactly at the computed level. Live execution can slip past it on gaps or fast markets, so realized losses can exceed the tested
xpoints.
Related instructions
%LOSS, stop loss as a percentage of the position price.$LOSS, stop loss as a cash amount.PPROFIT, take profit in points, the mirror instruction.%PROFIT, take profit as a percentage.BREAKEVEN, moves the stop or target to the entry price.PTRAILING, trailing stop expressed in points.POSITIONPRICE, the average entry price the distance is measured from.POINTSIZE, the size of one point in price units.STOP, overview of the stop instruction family.
