Scratching my head for the whole day what I am doing wrong
I add QQQ as a secondary instrument
protected override void Initialize()
CalculateOnBarClose = false;
Add("QQQ", PeriodType.Day, 1);
Add("QQQ", PeriodType.Day, 3);
But when I use the code below in OnBarUpdate()
Print(Time[0]);
Print(Opens[1][0]);
Print(Lows[1][1]);
Print(Highs[1][1]);
It returns 1 day old value for Opens[1][0] rather than for current day.
In back testing, it returns 129.89 as open on march 23, but that was actually open for march 22
In your expert opinion, what could I be doing wrong? Please kindly give your guidance on how to access the day open value of QQQ (added as a secondary instrument) at the time of market open in ninjascript at 9:30 est
////////////////////////////////////////////////////
the code is below:
protected override void OnBarUpdate()
{
if (Bars.FirstBarOfSession && FirstTickOfBar)
{
BarNumber = Bars.BarsSinceSession;
QQQFirstBarofSession = 0;
}
if (BarsInProgress ==1 && Bars.BarsSinceSession >= BarNumber && QQQFirstBarofSession == 0 )
{
Print(Time[0]);
Print(Opens[1][0]);
Print(Lows[1][1]);
QQQFirstBarofSession = 1;
}
Comment