In this strategy I want to make certain calculations at a certain time of day (2:00 AM EDT) and these calcs call data from both time frames. I'm using detailed prints to the Output window to print the calculations and debug the strategy.
I understand that I must check that have enough bars on the chart for both data series and I've tried various ways of using BarsInProgress and BarsArray to explicitly denote which data series I'm trying to call from which time frame. I basically need to make sure the strategy doesn't start running on the 5M time frame until I have enough data on the Daily time frame to calculate the following variable:
2) if (BarsInProgress == 0 && CurrentBar < 8650) return; // called from 5M TF
I'm posting the code that works best so far below. This code contains no trade logic yet because I'm trying first to get the calculations right before proceeding further.
Running this strategy from the 5M chart seems to print all the calculations correctly at the correct time, but it only prints for a small fraction of the backtested days, i.e. 2/14- 2/28/2011, when the strategy is running 1/1-7/10/2011. And it still prints the “out of range” error to the log file.
Q2: Why is this happening and how can I correct it?
Comment