NinjaScript > Language Reference > Strategy >


Print this Topic Previous pageReturn to chapter overviewNext page


Holds an array of Position objects that represent positions managed by the strategy. This property should only be used when your strategy is executing orders against multiple instruments.


Index value is based on the the array of Bars objects added via the Add() method. For example:


Primary Bars is ES 1 Minute
Secondary Bars is ES 3 Minute
Third Bars is ER2 1 Minute


Positions[0] == ES position
Positions[1] == Always a flat position, ES position will always be Positions[0]
Positions[2] == ER2 position


Property Value

An array of Position objects.


Positions[int index]


Property Of

Custom Strategy




protected override void Initialize()
    Add(Instrument, PeriodType.Minute, 5);
    Add("ER2 06-07, PeriodType.Minute, 5);
protected override void OnBarUpdate()
    Print("Primary position is " + Positions[0].MarketPosition);
    Print("ER2 positions is " + Positions[2].MarketPosition);
    // Alternative approach. By checking what Bars object is calling the OnBarUpdate()
    // method, we can just use the Position property since its pointing to the correct
    // position.
    if (BarsInProgress == 0)
         Print("Primary position is " + Position.MarketPosition);
    else if (BarsInProgress = 2)
         Print("Er2 position is " + Position.MarketPosition);