Navigation: Realtest Script Language > Syntax Element Details >

Shares or Contracts






Current Position Information


Returns the number of shares or contracts held in the current position


This element can be referred to as either Shares or Contracts, regardless of the type of instrument being traded.

The number returned is the number of shares (or contracts) held in the current position for the current strategy only.

To get the number of shares of the current symbol held in a different strategy, use Extern(strategy_name, Shares).

To get the number of shares of the current symbol held in all strategies, use Combined(Shares).

Note that Shares, when referenced alone (without Extern or Combined) is always a positive number, regardless of the side (long vs. short) of the position. However, when Extern(@strategy, Shares) is used, the return value is negative for short positions and positive for long positions. And when Combined(Shares) is used, the return value is the net position (long shares minus short shares) in that symbol across all strategies.

One typical use of Shares is to enforce a rule that only one strategy at a time can hold a position in a stock. This can be done by adding and Combined(Abs(Shares)) == 0 to every strategy's EntrySetup condition, or else by using a Template EntrySkip condition of Combined(Abs(Shares)) > 0.

Another common usage of Shares is in the standard IB commission calculation: Max(1.0, 0.005 * Shares).




Copyright © 2020-2022 Systematic Solutions, LLC