I am creating an strategy, step by step.
In this strategy I use primary Bars : 5 minutes, and add secondary Bars object : 60 minutes.
I try to find ( calculate ) supports and resistances in each dimension ( or Bars series).
Each support and resistance found will be added on Lists of supports and resistances.
Next step will be calculate ranges between supports and resistances...,
for example, using 3-4 supports and 3-4 resistances to calculate impulses and retracements between this supports and resistances.
The question is: How can I know the number of historical bars to begin calculations?
In the sample code ( see attached file), I write:
If ( CurrentBars[1] < 11 || CurrentBars[0]<11)
return;
// then , begin calculations for each BarsInProgress...
In the attached code, ( full of explanations to understand it), there is no problem when I Print,
but when I add into this code methods to calculate impulses and retracements, using at least 4 supports and 4 resistances,
and I try to Print the values for this impulses and retracements,
appears the error:
" error on calling 'OnBarUpdate' method on bar 1079. You are accessing an index with a value that is invalid
since it is out of range...."
I solved the problem changing CurrentBars[1] < 11 , increasing the value, to CurrentBars[1]<111)
With that change I can Print the values for impulses and retracements..... But I just only increased this number, I don't really know
how big it must be.....
Then, How can I know the number of CurrentBars that I need , at least, to begin calculations correctly, and Print all the values?
Thanks for read this.
Comment