SHARES

Category: ProBacktest

Definition: In ProBuilder programming language, SHARES is a keyword used to specify the number of shares involved in a trading order. This keyword is crucial in defining the scale of a transaction, whether buying or selling, in a trading strategy script.

Syntax:

[BUY|SELLSHORT] quantity SHARES [AT MARKET|AT price LIMIT|AT price STOP]

Example:

The following example demonstrates how to use the SHARES keyword in a short selling scenario based on the MACD indicator crossing below zero:


myMACD = MACD[12,26,9](close)
shortCondition = myMACD crosses under 0
IF NOT ShortOnMarket AND shortCondition THEN
    SELLSHORT 1 SHARES AT MARKET
ENDIF

This script calculates the MACD value using the specified parameters (12, 26, and 9) and checks if the MACD line crosses below zero, which is a common trading signal for a potential downtrend. If the market conditions meet the criteria and there is no existing short position, it initiates a sell short order for 1 share at the market price.

  • MACD (Moving Average Convergence Divergence) is a trend-following momentum indicator that shows the relationship between two moving averages of a security’s price. The MACD is calculated by subtracting the 26-period Exponential Moving Average (EMA) from the 12-period EMA.
  • The crosses under condition is used to identify when the MACD line crosses below the zero line, suggesting a potential sell signal.

This example illustrates the use of the SHARES keyword in a practical trading strategy, emphasizing its role in specifying the transaction volume in trading commands.

Related Instructions:

  • CASH probacktest
  • CONTRACT probacktest
  • LOT probacktest
  • Logo Logo
    Loading...