zubr:
It doesn't return the ATR value, it returns a handle . . . read the documentation and sample code.
Hi,
I try to program a simple script.
My question: How do I get the value of the ATR (average true range) indicator in a script? I've found the function "iATR" (https://www.mql5.com/en/docs/indicators/iatr) but it does not return the current ATR value. Any ideas?
This is the simple code to get ATR Value :
int MA_Period = 15; // The value of the averaging period for the indicator calculation int Count = 5; // Amount to copy int ATRHandle; // Variable to store the handle of ATR double ATRValue[]; // Variable to store the value of ATR ATRHandle = iATR(_Symbol,0,MA_Period); // returns a handle for ATR ArraySetAsSeries( ATRValue,true ); // Set the ATRValue to timeseries, 0 is the oldest. if( CopyBuffer( ATRHandle,0,0,Count,ATRValue ) > 0 ) // Copy value of ATR to ATRValue { for( int i=0;i<Count;i++ ) { Print(ATRValue[i]); // Print the value of the ATR } }
zubr:
Do you know how to get the ATR value? I haven't found the function yet.
Do you know how to get the ATR value? I haven't found the function yet.
Yes, I already told you what to do . . .
RaptorUK:
read the documentation and sample code.
read the documentation and sample code.
biantoro:
Thank you!
This is the simple code to get ATR Value :
Biantoro Kunarto:
Hi I write the same code but it returns zero. every element of the array is zero
This is the simple code to get ATR Value :
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I try to program a simple script.
My question: How do I get the value of the ATR (average true range) indicator in a script? I've found the function "iATR" (https://www.mql5.com/en/docs/indicators/iatr) but it does not return the current ATR value. Any ideas?
Thank you.
Best,
Chris