I am trying to convert an indicator to an EA...all works well with one frustrating exception.
One section of the routine sets an array element equal to a variable...eg: "myArray[myElement] = myVariable". myArray and myVariable are both defined as "double". This works perfectly fine in the indicator, but in the EA, after the statement is executed, myArray[myElement] is equal to zero...even though myVariable contains a value. I have put "Print" statements before and after to verify that myVariable contains a value...but myArray[Element] contains a value of zero before and after the statement gets executed.
It's probably something obvious, but I'd appreciate some direction...TIA.
[...] It's probably something obvious [...]
Are you sure the array is large enough? For example...
MyArray = 999; // Slot 2 doesn't exist; array has bounds 0 to 1
MessageBox("Value is not 999: " + MyArray);
It is defined in the EA the same way it is defined in the indicator...
Do indicators and EAs treat arrays differently?
Well...I just answered my own question...it turns out that they do treat arrays differently. When I was testing, I looked in the journals and never saw an indication of an error.
After I made the previous post, it occurred to me that although I used the "Print" function, I never used GetLastError() to see if the statement generated an error. Sure enough...I got an array index error.
Now that I know what the problem is, I can correct it...sure wish I knew where this is documented. Thanks, jjc.