I am trying to load within a strategy two instruments, the primary instument and the secondary instrument using the following code obtained from another post on the forum.
The output I am looking for is to show the ask, bid and last price for the secondary instrument but after running the strategy I find that it's only getting the Ask, Bid and Last data from the primary instrument?
Is there something that I am doing incorrectly?
protected override void Initialize()
{
Add("ES 09-12", PeriodType.Tick, 1, MarketDataType.Ask);
Add("ES 09-12", PeriodType.Tick, 1, MarketDataType.Bid);
Add("ES 09-12", PeriodType.Tick, 1, MarketDataType.Last);
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Checks if OnBarUpdate() is called from an update on the primary Bars
if (BarsInProgress == 0) //Main Chart interval
{
Print("This is the default instrument close : "+Close[0].ToString());
}
else if(BarsInProgress == 1) //Bid Tick Chart interval
{
Print("This is the instrument ask : "+Close[0].ToString());
}
else if(BarsInProgress == 2) //Ask Tick chart interval
{
Print("This is the instrumentName bid: "+Close[0].ToString());
}
else if(BarsInProgress == 3) //Ask Tick chart interval
{
Print("This is the instrumentName last: "+Close[0].ToString());
}
}
Thanks again and regards,
suprsnipes

Comment