I ran into a MaxBarsBack problem: code attached
When I use the strategy to pass a period length to the function call, it seems to be capped at 50 MaxBarsBack. I have tried setting the strategy's settings directly
Code: Select all
...
[Input]
public int period_length { get; set; }
[Input]
public int max_bars_back { get; set; }
...
protected override void StartCalc() {
Output.Clear();
// assign inputs
atr.period = period_length;
ExecInfo.MaxBarsBack = max_bars_back;
}
When I output the current ExecInfo.MaxBarsBack from the strategy, it shows 50. It does not matter what I set it to - 10 or 100, it reports 50.
Thinking that maybe the indicator needs its MaxBarsBack setting to be higher, I changed it to 100. And it will report that the setting is changed, but I still get the error from the strategy.
I tried getting and setting MaxBarsBack on the function but it will not return a call to Output.WriteLine. I cannot tell if this is the source of the error.
What is the real source of the error? The strategy? The indicator? Or the function? (Edit: I am sure it isn't the matching indicator, when I remove it from the chart and enter in a long period length like 90 or 100, the error still occurs)
How do I change the MaxBarsBack to allow any given length to work while still maintaining the benefits of a strategy that uses a calculation function and a related indicator to show the values?