The main point is this:
https://www.mql5.com/en/docs/customind/setindexbuffer
Note
Please note that you can't change the size for dynamic arrays set as indicator buffers by the function SetIndexBuffer(). For indicator buffers, all operations of size changes are performed by the executing sub-system of the terminal.
The terminal maintains the size of indicator buffers equal to each other and equal to the size of arrays that are parameters of OnCalculate()
int OnCalculate( const int rates_total, // size of input time series const int prev_calculated, // number of handled bars at the previous call const datetime& time[], // Time array const double& open[], // Open array const double& high[], // High array const double& low[], // Low array const double& close[], // Close array const long& tick_volume[], // Tick Volume array const long& volume[], // Real Volume array const int& spread[] // Spread array );The size of all those arrays will always be equal to rates_total
Vladislav Boyko #:
The main point is this:
The terminal maintains the size of indicator buffers equal to each other and equal to the size of arrays that are parameters of OnCalculate()
The size of all those arrays will always be equal to rates_totalThank you. Now it's clear that in my case it would even be wrong to use
SetIndexBuffer(2, MyBuffer, INDICATOR_CALCULATIONS);
I've created an indicator that calls an internal function. This function uses an array internally for intermediate calculations. So far, everything works. The indicator is displayed in the indicator chart. However, I'm wondering if I should define and use this indicator globally and register it to SetIndexBuffer:
Does this offer any performance benefits (e.g., caching), or is it only necessary for:
- The ability to use indexing (see https://www.mql5.com/en/docs/series/bufferdirection)
- The ability to make this buffer accessible to external indicators.