Topic: Alligator Indicator -- array out of range in 'New Strategy.mq4'
Hello,
I encountered this error when attempting to back test in Strategy Tester. This is a very simple strategy that uses a single indicator -- Alligator. I've attached the corresponding *.XML
"New Strategy EURUSD,M5: array out of range in 'New Strategy.mq4' (2145,24)"
I've run into these 'array out of range' errors a few times with other indicators. Usually I just hack the mql to get around it, but this time I thought I would ask for some help. It is always a 'for' loop that causes the problem when initializing a couple of Value properties to '0'. There is something wrong about parameter 'firstBar' that gets past into the method.
for(int bar=0; bar<firstBar; bar++)
{
indCompLong.Value[bar]=0;
indCompShort.Value[bar]=0;
}
Later in the method there is another 'for' loop that performs the actual assignments. So my hack is to substitute the second 'for' loop for the first one. The second 'for' loop looks like this:
for(int bar=firstBar; bar<Data.Bars; bar++)
Appreciate any help. Thanks.