This isn't a code question, more of an approach question.
I have an indicator I am working on that has a lookback period. The crossover period from Historical to real time is giving me fits.
The calculation is complicated and has ramifications for many bars (even beyond the lookback period).
Historical data works great but the crossover requires some of the calculations to be on the price[0] and some on [1] (I am using FirstTickOfBar).
I have found using
int barOffset = (Historical || CalculateOnBarClose) ? 0 : 1;
and then using barOffset in place of [0] or [1] for real time solves everything but the crossover period.
I have also found it helpful to color the first realtime bar when debugging a new indicator.
I always feel with issues like this there is a simple solution that is eluding me. Does anyone have any suggestions as to how they deal with this issue?
Best Regards,
Scott
Comment