ONMARKET

Category: ProBacktest

ONMARKET is a built-in function in the ProBuilder language used to determine if there is currently an open position in the trading system. This function is crucial for strategies that need to avoid entering multiple positions simultaneously or to ensure that certain actions are only taken when no positions are open.

Syntax:

ONMARKET

Example Usage:

IF NOT ONMARKET THEN
    BUY 1 CONTRACT AT MARKET
ENDIF

This example demonstrates how to use the ONMARKET function to check if there are no open positions. If there are no positions open, it executes a command to buy one contract at the market price.

  • The ONMARKET function returns a boolean value: true if there is at least one open position and false if there are no open positions.
  • It is commonly used in conditional statements to control trading actions, helping to prevent the accumulation of unwanted exposure by opening multiple positions.

This function is essential for maintaining discipline in trading strategies, ensuring that entries and exits are executed only under appropriate conditions.

Related Instructions:

  • LONGONMARKET probacktest
  • MARKET probacktest
  • SHORTONMARKET probacktest
  • Logo Logo
    Loading...