[Documentation error?] Indexing after binding
MQL4 Reference -> SetIndexBuffer:
| Note After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array. If you want to change the order of access to elements of the indicator array, use the ArraySetAsSeries() function after binding the array using the SetIndexBuffer() function. |
Seems like it's not true. Or am I misunderstanding something?
Yes you misunderstood.
It says you need to do it like this :
int OnInit() { SetIndexBuffer(0,buffer); ArraySetAsSeries(buffer,true); return(INIT_SUCCEEDED); }
And not like this :
int OnInit() { ArraySetAsSeries(buffer,true); Wrong way SetIndexBuffer(0,buffer); return(INIT_SUCCEEDED); }
It's clear. I'm talking about the first part of the quote:
"After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array"
"the array will be indexed as in common arrays" - this means that ArrayGetAsSeries() must return false, am I understanding it correctly?
double buffer[]; int OnInit() { SetIndexBuffer(0,buffer); Alert(isIndexedAsInCommonArrays(buffer) ? "Documentation is ok" : "Documentation error"); return(INIT_SUCCEEDED); } bool isIndexedAsInCommonArrays(const double &arr[]) { return(!ArrayGetAsSeries(arr)); }
It's clear. I'm talking about the first part of the quote:
"After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array"
"the array will be indexed as in common arrays" - this means that ArrayGetAsSeries() must return false, am I understanding it correctly?
isIndexedAsInCommonArrays() testing:
void OnStart() { double commonArray[]; string isOrIsNot = isIndexedAsInCommonArrays(commonArray) ? "is" : "is not"; Alert("Common array ", isOrIsNot, " indexed like in common array"); } bool isIndexedAsInCommonArrays(const double &arr[]) { return(!ArrayGetAsSeries(arr)); }
It's clear. I'm talking about the first part of the quote:
"After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array"
"the array will be indexed as in common arrays" - this means that ArrayGetAsSeries() must return false, am I understanding it correctly?
MQL4 Reference -> SetIndexBuffer:
Note
After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array. If you want to change the order of access to elements of the indicator array, use the ArraySetAsSeries() function after binding the array using the SetIndexBuffer() function.
Seems like it's not true. Or am I misunderstanding something?