Calling an indicator as a function MQL5

 

I'm trying to call an indicator outside the ontick function for my user defined function but unfortunately it's producing an error, i tried calling the indicator inside the ontick function and it's working perfectly but error arises as i do the same outside the ontick function

   double emaArray[]; //Array for ema; default values would be from left to right
   ArraySetAsSeries(emaArray,true); // assign the emaarray from right to left
   double emaHandle = iMA(_Symbol,_Period,200,0,MODE_EMA,PRICE_CLOSE); // 200 ema definition
   CopyBuffer(emaHandle,0,0,11,emaArray); // assign the emaarray with ema handle
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
Predefined Macro Substitutions - Named Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Renz Carillo:

I'm trying to call an indicator outside the ontick function for my user defined function but unfortunately it's producing an error, i tried calling the indicator inside the ontick function and it's working perfectly but error arises as i do the same outside the ontick function

Remember the main rule: in MQL5 the indicator handle needs to be received once (it is optimal to do this in the OnInit function).
How to start with MQL5
How to start with MQL5
  • 2020.03.05
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
Reason: