Script to get value of indicator ATR

 

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 

Documentation on MQL5: Technical Indicators / iATR
Documentation on MQL5: Technical Indicators / iATR
  • www.mql5.com
Technical Indicators / iATR - Documentation on MQL5
 
zubr:

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?

It doesn't return the ATR value,  it returns a handle . . .  read the documentation and sample code.
 
RaptorUK:
It doesn't return the ATR value,  it returns a handle . . .  read the documentation and sample code.
Do you know how to get the ATR value? I haven't found the function yet.
 

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.

Yes,  I already told you what to do . . .

RaptorUK:
   read the documentation and sample code.
 
biantoro:

This is the simple code to get ATR Value :

Thank you!
 
Biantoro Kunarto:

This is the simple code to get ATR Value :

Hi I write the same code but it returns zero. every element of the array is zero