Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 has event handling?
stangstang
113
stangstang 2011.05.05 15:02 

i  write such code in experts , it can work !

#include <Indicators\Trend.mqh>

CiMA  *ma;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   ma=new CiMA;
   ma.Create(Symbol(),PERIOD_CURRENT,20,0,MODE_EMA,PRICE_CLOSE);
   ma.Refresh(-1);
   Alert(ma.Main(0));
   return(0);

 

the successed result is :

result in expert 

 

but ,the same code is used in indicator that are create by me !,it can not work !

 #include <Indicators\Trend.mqh>
CiMA  *ma;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   ma=new CiMA;
   ma.Create(Symbol(),PERIOD_CURRENT,20,0,MODE_EMA,PRICE_CLOSE);
   ma.Refresh(-1);
   Alert(ma.Main(0));
   return(0);
}

the result is  not right , please see:

result in indicator that is create by me

why make the different result ?  who can tell you ,thank you very much!

/
To add comments, please log in or register