The TRAILING instruction in ProBuilder language is used to set a trailing stop order, which is a dynamic stop order set at a specific number of price units away from the current market price. This type of stop adjusts as the price of the asset moves, providing a flexible approach to managing risk while allowing potential profits to grow.
Syntax:
SET STOP TRAILING x
Where x represents the number of points the trailing stop should be set away from the current market price.
Example:
// Define moving averages
i1 = average(close)[100]
i2 = average(close)[5]
// Define entry and exit conditions
tradeinitiate = Close > i1 AND Close < i2 AND Low[3] > Low[2] AND Low[2] > Low[1] AND Low[1] > Low
tradeclose = Close > Close[1]
// Execute trade
IF NOT LongOnMarket AND tradeinitiate THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
IF LongOnMarket AND tradeclose THEN
SELL AT MARKET
ENDIF
// Set a trailing stop loss
SET STOP TRAILING 10
In this example, a trailing stop is set to maintain a distance of 10 points from the current market price. This stop will adjust as the market price moves, securing profits while limiting potential losses.
- The trailing stop is particularly useful in volatile markets where price swings can occur rapidly.
- It allows traders to stay in the market as long as the price is moving favorably, but exits the trade if the price changes direction by a specified amount.
This instruction is essential for traders who want to manage their risk dynamically, adapting their strategies to market conditions without needing to manually reset their stop levels.