Does somebody know how to avoid the error array out of range
when trying to display long number of bars (lets say 7000) in an indicator buffer?
I had a similar issue, that I always got "Array out of range
" errors for one of my buffers. I checked with ArraySize()
, which returned 0
.
In the end I just forgot to call SetIndexBuffer(...)
for this buffer array in onInit() {...}
of my indicator.
Since I was using an internal buffer without drawing lines, I used the IndicatorBuffers()
function to increase the amount of buffers first and then registered my additonal buffer using SetIndexBuffer(...)
.
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
IndicatorBuffers(5);
//buffers with #properties settings
SetIndexBuffer(0,Buffer1);
SetIndexBuffer(1,Buffer2);
SetIndexBuffer(2,Buffer3);
SetIndexBuffer(3,Buffer4);
//additional buffer without #properties
SetIndexBuffer(4,AdditionalBuffer);