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.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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);
// ....
}