CIATR

 

Hello,


I tried to use for the ATR calculation the include files, 

but I always get Empty Value out


here the script

#include <Indicators\Indicator.mqh>      CIndicator _indi;
#include <Indicators\Oscilators.mqh>     CiATR atr;


void OnStart()
  {

   atr.Create(_Symbol,PERIOD_CURRENT,14);
   
   Print(atr.Main(0));
   
  }

is there something wrong?


https://www.mql5.com/en/docs/standardlibrary/technicalindicators/oscillatorindicators/ciatr/ciatrcreate

Documentation on MQL5: Standard Library / Indicators / Oscillators / CiATR / Create
Documentation on MQL5: Standard Library / Indicators / Oscillators / CiATR / Create
  • www.mql5.com
Create(string,ENUM_TIMEFRAMES,int) - CiATR - Oscillators - Indicators - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

ok,

now I found it out


#include <Indicators\Oscilators.mqh>     CiATR atr;


void OnStart()
  {
//---
   //atr = new CiATR;
   
   atr.Create(_Symbol,PERIOD_CURRENT,14);
   atr.Refresh(-1);
   
  Print(atr.Main(0));
  }

but I don't know, why I have to refresh it


and is there a way to deinitialiszize?

 
Maybe it is 
atr.Destroy();

But i didn't test it so its best if you looked into the code it must be there.

Also you could use a fast timer.

Reason: