LIMIT

Category: ProBacktest

The LIMIT instruction in ProBuilder language is used to place a limit order in the trading strategy. A limit order is an order to buy or sell a security at a specific price or better. In the context of automated trading, this instruction allows traders to specify the exact price at which they are willing to execute a trade, rather than executing at the current market price.

Syntax:

BUY AT x LIMIT

Example:

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0
IF long THEN
    BUY 1 LOT AT close-10 LIMIT
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 executed with a limit order to buy one lot when the MACD crosses over zero, at a price 10 points below the closing price.

  • The MACD[12,26,9](close) function calculates the MACD using a fast moving average of 12 periods, a slow moving average of 26 periods, and a signal line of 9 periods based on the closing prices.
  • The condition long = myMACD crosses over 0 checks if the MACD line has crossed over the zero line from below, which is typically considered a bullish signal.
  • The LIMIT order ensures that the buy order will only be executed at the specified price (close-10) or better, providing control over the execution price.

This instruction is particularly useful in strategies where the entry price is crucial for the trade setup. It helps in avoiding slippage and ensures that the trade is executed within the parameters set by the trader.

Related Instructions:

  • STOP (pending) probacktest
  • Logo Logo
    Loading...