-
Don't try to do that. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)
Just get the value(s) of the indicator(s) into EA/indicator (using iCustom) and do what you want with it.
You should encapsulate your iCustom calls to make your code self-documenting.
Detailed explanation of iCustom - MQL4 programming forum #33 2017.05.23 -
int ATRdef = iATR(_Symbol,_Period,10); ArraySetAsSeries(ATRvalues,true); CopyBuffer(ATRdef,0,0,3,ATRvalues);
Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to call indicators in MQL5 - MQL5 Articles 12 March 2010

- 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 ,
i'd like to calculate Keltner channel for my EA , i only need the calculations not to make it as an indicator to display on the terminal
i have calculated the (Moving average & Average true rage ) but can't get to calculate Keltner channel right
Ketlner channel calculations that i'd like to make :
MiddleLine=EMAUpperChannelLine=EMA+2∗ATRLowerChannelLine=EMA -2∗ATR
This is my attempt , please help find the error!!