LOSS

Category: ProBacktest

The LOSS instruction in ProBuilder language is used to set a stop loss for an open trading position. A stop loss is a predefined price level at which a losing position will be closed to prevent further losses. This instruction is crucial for risk management in trading strategies.

Syntax:

SET STOP LOSS x

Here, x represents the distance from the average position price at which the stop loss should be set. The value of x should be specified in the price units of the traded instrument.

Example:

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0
IF NOT LongOnMarket AND long THEN
    BUY 1 CONTRACTS AT MARKET
    SET STOP LOSS 0.0050
ENDIF

In this example, a trading strategy is implemented where a buy order is placed if the MACD indicator crosses over zero and there is no long position already in the market. After placing the buy order, a stop loss is set 0.0050 units away from the average position price. This example assumes the instrument is traded with five decimal places.

  • The MACD (Moving Average Convergence Divergence) indicator is used here to determine the entry point for the trade. It is a trend-following momentum indicator that shows the relationship between two moving averages of a security’s price.
  • The crosses over condition checks for a crossover of the MACD line from below to above zero, indicating a potential entry point for a long position.
  • The SET STOP LOSS command is crucial for managing potential losses by specifying the price level at which the position should be automatically closed to prevent further losses.

This instruction is essential for traders using automated trading systems in ProBuilder, as it helps in implementing effective risk management strategies.

Related Instructions:

  • %LOSS probacktest
  • PLOSS probacktest
  • Logo Logo
    Loading...