BUY

Category: ProBacktest

The BUY instruction in ProBuilder language is used to initiate a long position in a trading strategy. This command is essential for strategies that aim to profit from an anticipated increase in a financial instrument’s price.

Syntax:

BUY x SHARES

Here, x represents the number of shares to buy.

Example:

IF NOT LongOnMarket AND LongConditions THEN
    BUY 1 SHARES AT MARKET
ENDIF

This example demonstrates the use of the BUY instruction within a conditional statement. The command executes only if the trading system is not already in a long position (LongOnMarket) and certain conditions for going long (LongConditions) are met. The instruction BUY 1 SHARES AT MARKET is executed, meaning one share is purchased at the current market price.

  • LongOnMarket: A boolean variable that checks if there is already an open long position in the market.
  • LongConditions: A user-defined condition or set of conditions that must be true to initiate a long position.

This command is fundamental for implementing trading strategies that require entering the market at specific conditions. It is crucial for traders to define the conditions under which they want to enter the market clearly and precisely to use the BUY instruction effectively.

Related Instructions:

  • EXITSHORT probacktest
  • SELL probacktest
  • SELLSHORT probacktest
  • Logo Logo
    Loading...