Set Target Loss
Set Target Loss places the exit target at a loss distance from entry in ProBacktest and ProOrder, in points, percent, currency, or price units. Syntax and use.
Syntax
SET TARGET PLOSS x
SET TARGET %LOSS x
SET TARGET $LOSS x
SET TARGET LOSS xNotes: the syntax block on the source page lists PROFIT-unit spellings, an editing error inconsistent with its own parameter list and example. The forms above follow the unit definitions and the SET TARGET PLOSS example given in the source body.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | number | none | Loss distance between the entry price and the target, in the unit implied by the variant, points, percent, account currency, or price units. |
How it works
A normal SET TARGET PROFIT places the exit target on the winning side of the entry. Set Target Loss inverts that: the target sits at a loss distance from the entry, below it for a long position and above it for a short. The trade then closes at a small, chosen loss if price recovers to that level, instead of waiting for a full round trip back to breakeven or beyond.
The command is a generalization of SET TARGET BREAKEVEN, which is the special case of exiting at exactly zero. Set Target Loss accepts a controlled negative amount instead, which is useful for escaping a trade that has moved hard against the position: any bounce that recovers part of the drawdown closes the trade before the move can resume.
Timing is the critical detail, mirrored from Set Stop Profit. A target on the losing side of the entry is only meaningful while price is beyond it, that is, while the open loss exceeds x. Called too early, the target sits on the wrong side of the current price and the position closes immediately at the prevailing market. The instruction therefore belongs behind a guard that checks both an open position and a sufficient open loss.
Examples
Example 1, Escaping a losing long at ten points (ProOrder)
// after 20 points of drawdown, exit on any bounce at a 10-point loss
IF longonmarket AND tradeprice - close >= 20 * pointsize THEN
SET TARGET PLOSS 10
ENDIFOnce the long is 20 points under water, the exit target moves to 10 points below entry. The SET TARGET PLOSS 10 call is the example from the official reference, wrapped in the required guards; a recovery of half the drawdown now closes the trade at a contained loss.
Example 2, Percent-based escape level (ProOrder)
DEFPARAM CumulateOrders = false
IF NOT onmarket AND close CROSSES OVER Average[50](close) THEN
BUY 1 CONTRACT AT MARKET
SET STOP %LOSS 3
ENDIF
// two percent against the position: aim to get out at a one percent loss
IF longonmarket AND close <= tradeprice * 0.98 THEN
SET TARGET %LOSS 1
ENDIFThe trade starts with a wide 3 percent stop. After a 2 percent adverse move, the target moves to the 1 percent loss level, so a partial recovery exits the trade well before the stop.
Example 3, Staged escape levels in price units (ProBacktest)
// deepen the accepted exit loss as the drawdown grows
IF shortonmarket THEN
drawdown = close - tradeprice
IF drawdown >= 100 THEN
SET TARGET LOSS 50
ELSIF drawdown >= 50 THEN
SET TARGET LOSS 20
ENDIF
ENDIFFor a short position the loss side is above the entry. The accepted exit loss widens in steps with the drawdown, 20 price units after a 50-unit move, 50 units after a 100-unit move, ordered largest first so the deepest level stays active.
Common errors and gotchas
- Called before the loss exists. If the open loss is smaller than x, the target lies on the wrong side of the current price and the position exits at once. Always pair the command with a condition on the drawdown, such as
tradeprice - close >= thresholdfor a long. - One target slot. Set Target Loss writes to the same internal target as
SET TARGET PROFITandSET TARGET BREAKEVEN. The most recent call wins, so a later profit target silently discards the escape level. - Unit mix-ups across variants. PLOSS is points, %LOSS percent, $LOSS account currency, LOSS price units. On instruments where point size and price unit differ, the wrong variant places the level far from the intended price.
- Source syntax typo. The upstream reference prints PROFIT spellings in its syntax block while describing loss units. The LOSS spellings shown above match the parameter definitions and the worked example.
Related instructions
Set Stop Profit, the mirrored command, a stop placed at a profit distance.SET, prefix of all order management declarations.TARGET, the exit-target side of the SET instruction.PLOSS, loss distance measured in points.%LOSS, loss distance measured in percent.$LOSS, loss distance measured in account currency.LOSS, loss distance measured in price units.BREAKEVEN, exits at exactly zero, the special case of this command.TRADEPRICE, the entry price of the current position.
