Download MetaTrader 5

CICustom::GetData null

To add comments, please log in or register
Store your source codes in MQL5 Storage. It is secure!
Alexess
17
Alexess 2016.06.21 01:46 

I don't know where I went wrong creating a custom indicator, but the function GetData always return null (value 1.797693134862316e+308).

Any help is welcome.

#include <Indicators\Custom.mqh>

CiCustom *m_hilo = new CiCustom();
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   MqlParam params[4];
   //---
   params[0].type         = TYPE_STRING;
   params[0].string_value = "Examples\\Custom Moving Average.ex5";
   params[1].type          = TYPE_INT;
   params[1].integer_value = 36;
   params[2].type          = TYPE_INT;
   params[2].integer_value = 0;
   params[3].type          = TYPE_INT;
   params[3].integer_value = MODE_EMA;

   //--- Object initialization
   if(!m_hilo.Create(Symbol(), Period(), IND_CUSTOM, 4, params))
   {
      printf(__FUNCTION__+": error");
      return(INIT_FAILED);
   }
   
   //--- number of buffers
   if(!m_hilo.NumBuffers(1))
      return(INIT_FAILED);
//---
   return(INIT_SUCCEEDED);
  }
  
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   Print("GetData: ", m_hilo.GetData(0, 1));
   
  }
//+------------------------------------------------------------------+
Alexess
17
Alexess 2016.06.21 02:58  
Alexess:

I don't know where I went wrong creating a custom indicator, but the function GetData always return null (value 1.797693134862316e+308).

Any help is welcome.

Someone told me what is my mistake: I don't refresh de indicator's data. Just call m_hilo.Refresh() inside OnTick.
To add comments, please log in or register