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.
ONMARKET
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.
This function is essential for maintaining discipline in trading strategies, ensuring that entries and exits are executed only under appropriate conditions.