What is the code to get the Moving Average indicator value?
Look up iMA in the documentation.
Look up iMA in the documentation.
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
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 start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
But that code only returns the number 10
Show your code that only returns the number 10.
Show your code that only returns the number 10.
Comment(iMA(_Symbol,_Period,20,0,MODE_EMA,PRICE_CLOSE));
this code show me number 10.
this code show me number 10.
That is the code to get the handle.
Show the code where you use CopyBuffer.
I got the same...
Do i have to use the CopyBuffer?
I am using it directly:
for (i = 0; i < 2 + 1; i++) { ma[i]=0; ma_off[i]=0; ma[i] = iMA(_Symbol, timeframe_ma, period, i, MODE_SMA, PRICE_CLOSE); ma_off[i] = iMA(_Symbol, timeframe_ma, period, i+offset, MODE_SMA, PRICE_CLOSE }
Yes, you have to use CopyBuffer in MQL5. Please read the documentation ...
Moving Average
Gets data of a specified buffer from a specified indicator into an array
So the solution in this thread is something like this.
double ama[]; ResizeArray(ama,3); int ma = iMA(_Symbol, timeframe_ma, period, 0, MODE_SMA, PRICE_CLOSE); //ma_off = iMA(_Symbol, timeframe_ma, period, offset, MODE_SMA, PRICE_CLOSE); CopyBuffer(ma,0,0,2,ama); //CopyBuffer(ma_off,0,0,2,ama_off);EDIT:
Why do i cant get a proper value from an IMA like this? With a offset of -6 ?
double ama[]; ResizeArray(ama,3); ma_off = iMA(_Symbol, timeframe_ma, period, -6, MODE_SMA, PRICE_CLOSE); CopyBuffer(ma_off,0,0,2,ama_off); Comment( "SMA OFF -6 ", ama_off[0];

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use