1) In the attached .jpg file is the Initialize() method for a strategy. Will the BarsRequired = 30; statement require 30 bars for each of the 3 preceding Add() statements or only the last Add() statement?
Background:
2) In this particular strategy I use or reference functions that use BarsRequired in a few places and I want to make sure I understand what's happening:
a.] The strategy calls an indicator and this indicator, let's call it Indicator1, has BarsRequired = 16 in its Initialize method.
b.] In the strategy, there is a function which uses Indicator1. This function uses BarsArray[2] which are 1 day bars. The function requires 30 bars. Thats's why I've included BarsRequired = 30 in the strategy Initialize() method.
3) So, according to the simple math I should set DaysToLoad = 16 + 30 = 46 and I set min bars required = 0 since all of the bars required by the strategy are already addressed in the BarsRequired statements
4) However, I'm not able to get the variables to populate with sufficient data unless I set DaysToLoad >= 66.
Questions:
1) Why do I need need to add the 20 extra bars (66 - 46 = 20) to get sufficient data into the function included in my strategy code?
2) If I use BarsRequired throughout my indicator and strategy code will that supersede min bars required? If so, then why would I ever use min bars required? I'd really like to avoid using min bars required b/c it's caused a lot of problems for my strategy.
3) Why does min bars required work differently in Backtest mode vs. Real-time trading? In backtest mode I didn't need BarsRequired statements at all. I just set min bars required = 66 and the code ran properly. But, in strategy mode, if I exclude BarsRequired statements and set DaysToLoad = 66 and min bars required = 66 the code doesn't run. I can't even force an exception or an error message to occur. BTW, I wasted 2 weeks trying to get my code to run before I figured out this difference b/t backtest mode and real-time mode and how to correct for it.
Lastly, while I'm glad I figured this out on my own, I can't believe that in my many requests for help from NT support on this issue that no one mentioned this difference b/t min bars required in backtest vs. real-time mode.
Comment