Is an intermediate array with INDICATOR_CALCULATIONS required?

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:

SetIndexBuffer(2, MyBuffer, INDICATOR_CALCULATIONS); 

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.

Documentation on MQL5: Indexing Direction in Arrays, Buffers and Timeseries / Timeseries and Indicators Access
Documentation on MQL5: Indexing Direction in Arrays, Buffers and Timeseries / Timeseries and Indicators Access
  • www.mql5.com
The default indexing of all arrays and indicator buffers is left to right. The index of the first element is always equal to zero. Thus, the very...

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_total

Thank you. Now it's clear that in my case it would even be wrong to use

SetIndexBuffer(2, MyBuffer, INDICATOR_CALCULATIONS); 
To add comments, please log in or register