hi all,
from what i read in the documentation its the Average Trading Range, and as I imagine the value should be a single number.
But when i use iATR I reailized that the result value is an array instead, should I only use the first ([0]) value of the array?
Thanks.
Example (for the iMA indicator) - displaying the last three values on the chart
Forum on trading, automated trading systems and testing trading strategies
Vladimir Karputov, 2020.11.13 06:01
Receiving data from an indicator in an MQL5.
Scheme:
An example for the iMA indicator:
It is an average — it changes with every new bar. Just like a moving average.
That value is the average of the last length-1 bars plus the forming bar. The forming bar starts at zero length. Don't use zero (except, perhaps, near the end of period).
Example (for the iMA indicator) - displaying the last three values on the chart
thanks but i found that seems the array do not need to use ArraySetAsSeries() , looks like the result buffer is already starting from the right most candle.
It is an average — it changes with every new bar. Just like a moving average.
That value is the average of the last length-1 bars plus the forming bar. The forming bar starts at zero length. Don't use zero (except, perhaps, near the end of period).
thanks a lot, and here is my code, I found that when calling iATR , unless i put 0 for the last param, all the other values I put would result in the same array, is it true? and I find that i don't actually need to reverse the ATR[] as it starts from the right most ( most recent ) candle.
Please let me know if I am wrong, thanks.
void CheckATR(){ double ATR[]; ArrayResize(ATR,50); hATR = iATR(_Symbol,_Period,15); //ArraySetAsSeries( ATR, true); CopyBuffer( hATR, 0, 0, 40, ATR ); //take number of average value for ( int i=0 ; i<ArraySize(ATR) ; i++ ){ Print("the ATR " + i + " is " + ATR[i]); } }
thanks but i found that seems the array do not need to use ArraySetAsSeries() , looks like the result buffer is already starting from the right most candle.
You should always use ArraySetAsSeries (***, true) - this way the index '0' in the array will correspond to the rightmost bar on the chart (of course, if you copy from the '0' bar). Study the example I gave.
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.
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
thanks a lot, and here is my code, I found that when calling iATR , unless i put 0 for the last param, all the other values I put would result in the same array, is it true? and I find that i don't actually need to reverse the ATR[] as it starts from the right most ( most recent ) candle.
Please let me know if I am wrong, thanks.
void CheckATR(){ double ATR[]; ArrayResize(ATR,50); hATR = iATR(_Symbol,_Period,15); //ArraySetAsSeries( ATR, true); CopyBuffer( hATR, 0, 0, 40, ATR ); //take number of average value for ( int i=0 ; i<ArraySize(ATR) ; i++ ){ Print("the ATR " + i + " is " + ATR[i]); } }
Please read the help. Please read the examples given to you. In MQL5, the indicator handle MUST BE RECEIVED ONCE !!!. You cannot create a new indicator at every tick!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi all,
from what i read in the documentation its the Average Trading Range, and as I imagine the value should be a single number.
But when i use iATR I reailized that the result value is an array instead, should I only use the first ([0]) value of the array?
Thanks.