STOP (pending)

Category: ProBacktest

The STOP (pending) instruction in ProBuilder language is used to place a stop order at a specified price level. This type of order is crucial in trading strategies for managing risk by specifying a price at which a position should be automatically closed to prevent further losses. The ‘pending’ aspect of this instruction indicates that the order remains inactive until the price reaches the stop level, and it must be re-placed at the beginning of each new bar if not triggered.

Syntax:

BUY AT x STOP

Example:

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0
IF long THEN
    BUY 1 LOT AT close+10 STOP
ENDIF

In this example, a Moving Average Convergence Divergence (MACD) indicator is used to determine the trading signal. The MACD is a trend-following momentum indicator that shows the relationship between two moving averages of a security’s price. The trade is initiated with a stop order to buy 1 lot if the MACD crosses above the zero line, indicating a potential upward trend. The stop order is placed 10 points above the closing price.

  • MACD[12,26,9](close): This function calculates the MACD using a fast EMA of 12 periods, a slow EMA of 26 periods, and a signal line of 9 periods based on the closing prices.
  • long = myMACD crosses over 0: This condition checks if the MACD line crosses over the zero line from below, which is typically considered a bullish signal.
  • BUY 1 LOT AT close+10 STOP: This instruction places a stop order to buy one lot when the price reaches 10 points above the current closing price.

This documentation should help beginners understand how to use the STOP (pending) instruction in ProBuilder to manage risk effectively in their trading strategies.

Logo Logo
Loading...