Download MetaTrader 5

how to get data from calling technical indicator class ?

To add comments, please log in or register
Take active part in the life of the community. Improve your rating!
stangstang
113
stangstang 2010.11.22 17:39 

      generaly , if you want to get indicator data, you can use the code such as:

   double macd[];
   int macdHandle=iMACD(Symbol(),PERIOD_CURRENT,12,26,9,PRICE_CLOSE);
   ArraySetAsSeries(macd,true);
   CopyBuffer(macdHandle,0,0,100,macd);
   printf("%s  %f  %f   %f",Symbol(),macd[0],macd[1],macd[2]); 

     now  ,l  see class CiMACD that is technical indicator class ,in order to get data from it ,

     i use the code such as:

  

   CiMACD imacd;
   imacd.Create(NULL,PERIOD_CURRENT,12,26,9,PRICE_CLOSE);
   printf("%d ,%d ,%d",imacd.FastEmaPeriod(),imacd.SlowEmaPeriod(),imacd.SignalPeriod());
   printf("%f, %f",imacd.Main(0),imacd.Signal(0));
   return(0);

     

      but the result is that imacd.main(0) and imacd.Signal(0) are empty,i study help mq5 referances and have 

      no resolution ,l wish someone can help me ,thank you ! 

Documentation on MQL5: Standard Library / Classes for working with Indicators / Oscillators / CiMACD
  • www.mql5.com
Standard Library / Classes for working with Indicators / Oscillators / CiMACD - Documentation on MQL5
Alexey Da
Moderator
6606
Alexey Da 2010.11.23 10:53  

Please, read this topic (https://www.mql5.com/en/docs/standardlibrary/technicalindicators/CIndicators/CIndicator

You forgot to call method

imacd.Refresh(OBJ_ALL_PERIODS);

You should call Refresh method every time you want to get the most fresh data of indicator.

Documentation on MQL5: Standard Library / Classes for working with Indicators / Base classes / CIndicator
  • www.mql5.com
Standard Library / Classes for working with Indicators / Base classes / CIndicator - Documentation on MQL5
stangstang
113
stangstang 2010.11.23 11:23  
alexvd:

Please, read this topic (https://www.mql5.com/en/docs/standardlibrary/technicalindicators/CIndicators/CIndicator

You forgot to call method

You should call Refresh method every time you want to get the most fresh data of indicator.

Thank you very much ,i  feel technical class is easy to use .

l  like mql5! 

To add comments, please log in or register