I just made my trading strategy all nice and ready to go, but ran into an odd incident that maybe someone out here can explain.
I have a line in my code that says
if(Bars.PercentComplete < 1)
return;
This is something I am using to simulate CalculateOnBarClose = true for only certain conditions, whereas I have to have CalculateOnBarClose = false hard-set or else other things won't work right.
Anyway, in backtesting / strategy analyzer the things run great, because it would calculate properly and do the trades, etc etc, but when I open a live chart and start the strategy, the historical trades aren't showing up, and I have narrowed down to exactly why:
Print(Bars.PercentComplete.ToString()); is running every time OnBarUpdate() is being called, and in strategy analyzer, it's printing 1.00, 1.00, 1.00 on every bar like it should.
But in the historical data on my trading chart, it's printing 0.59, 0.59, 0.59 as the percent complete for all previous daily bars.
Can anyone help me speculate why it's not calling those historical daily bars 100% complete? Thanks!
** Edit: For now, I just changed my code to not do a return; if bars.percentcomplete < .59, and it's working fine on both real charts and strategy analyzer -- but can anyone tell me why the number is .59 and not 1.00 on historical daily bars? Thx!
** Edit 2: No, sorry, it's not working fine.. because I'm getting onbarupdate being calculated on every tick again instead of only when the bar percent is fully complete, and it's just saying that bars.percentcomplete = 0.59 right now on every tick during the day
Comment