Arrays in build 198 not initialised
int ArrayInitialize( double&array[], double value)
Sets all elements of a numeric array to the same value. Returns the count of initialized elements.
Note: It is not recommended to initialize index buffers in the custom indicator init() function as such functions are initialized automatically with an "empty value" at allocation and re-allocation of buffers.
Sets all elements of a numeric array to the same value. Returns the count of initialized elements.
Note: It is not recommended to initialize index buffers in the custom indicator init() function as such functions are initialized automatically with an "empty value" at allocation and re-allocation of buffers.
this has uncovered sloppy coding on my part more than anything else. While variables are initialised to zero or "" when declared, the contents of arrays are not. In fact, they (usually?) contain the value stored in the previous execution of start(). At least this is certainly the case with string arrays.
I have now written three initialisation routines like this one for string, double and int arrays
void InitialiseStringArray(string& arr[])
{
for (int i = 0 ; i < ArraySize(arr) ; i++) arr[i] = "";
}
and declare arrays like this
start()
{
string strItems[10]; InitialiseStringArray(strItems);
// ....
}