hello forum,
I am brand new with MetaEditor. I have been looking at some tutorials and I am making some progress. I can now get quite a lot done, except for one very important and basic thing... Making array works... What am I doing wrong... I keep getting the "array out of range code". only on my own buffer. I went to the very basic and created the most simple indicator possible to troubleshoot and even that isn't working. Why is ABuffer not working? Thanks in advance
Er... your code compiles and runs without any error on my pc... ... ... ...
Er... your code compiles and runs without any error on my pc... ... ... ...
Darn... I might try to reinstall MT5 then. cause for me it works only if I don't put ABuffer[i] = price[i];
Thanks for trying it out!
Darn... I might try to reinstall MT5 then. cause for me it works only if I don't put ABuffer[i] = price[i];
Thanks for trying it out!
Ah... MT5? I tried on MT4... LOL
Ok, on MT5 I do see array out of range error, but all you have to do is this:
ArrayResize(ABuffer,rates_total);
Add this before your 'for' loop.
Constant |
Type |
Description |
indicator_buffers |
Number of buffers for indicator calculation |
|
indicator_plots |
Number of graphic series in the indicator |
Language Basics / Preprocessor / Program Properties (#property) - Reference on algorithmic/automated trading language for MetaTrader 5
Add this before your 'for' loop.
You do not resize buffers.
Ah... MT5? I tried on MT4... LOL
Ok, on MT5 I do see array out of range error, but all you have to do is this:
Add this before your 'for' loop.
You do not resize buffers.
Custom Indicators / SetIndexBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
You do not resize buffers.
Thank you for pointing that out :).
@La_patates , whether to use ArrayResize() or not depends on whether you want to access the values of that array outside of your indicator. I saw you used "INDICATOR_CALCULATIONS", so I assumed that you're only going to use ABuffer within the indicator. But I could be wrong, after all you did call SetIndexBuffer().
So if you do want to access it in your EA, the orthodox solution would be to figure out why ABuffer wasn't already resized properly by SetIndexBuffer(). I suspect you don't have these lines (or did not use the correct numbers):
#property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 1
With these lines, you don't need to use ArrayResize(). However, if my assumption was right, then you need not SetIndexBuffer() for ABuffer, and then you'll need to use ArrayResize() - Whichever you need, there's a solution.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello forum,
I am brand new with MetaEditor. I have been looking at some tutorials and I am making some progress. I can now get quite a lot done, except for one very important and basic thing... Making array works... What am I doing wrong... I keep getting the "array out of range code". only on my own buffer. I went to the very basic and created the most simple indicator possible to troubleshoot and even that isn't working. Why is ABuffer not working? Thanks in advance