Download MetaTrader 5

getting init failed on this code

To add comments, please log in or register
n22alpha
63
n22alpha  

Hi guys I seem to be getting init failed when I try this code could someone help me?? thanks alot.

int OnInit(void)
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),LowerTime,Expert_EveryTick,Expert_MagicNumber))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(-1);
     }
//--- Creation of signal object

//--- set MagicNumber for your orders identification
   trd.SetExpertMagicNumber(Expert_MagicNumber);
   trd.SetDeviationInPoints(slippage);
//--- order filling mode, the mode allowed by the server should be used
   trd.SetTypeFilling(ORDER_FILLING_RETURN);
//--- what function is to be used for trading: true - OrderSendAsync(), false - OrderSend()
   //trade.SetAsyncMode(true);
   
   if(bol_bands_ht==NULL || _ma_ht == NULL || bol_bands_lt==NULL || _ma_lt == NULL)
     {
      //--- failed
      Print("Error creating signal.");
      return(-2);
     }
     
     bool bolcreate = bol_bands_ht.Create(Symbol(),HigherTime, Bol_Period, 0, Bol_Dev, PRICE_CLOSE);
     bool macreate = _ma_ht.Create(Symbol(), Period(), MA_period, 0, MODE_EMA, PRICE_CLOSE);
     bool bolcreate_two =  bol_bands_lt.Create(Symbol(),LowerTime, Bol_Period, 0, Bol_Dev, PRICE_CLOSE);
     bool macreate_two = _ma_lt.Create(Symbol(), LowerTime, MA_period, 0, MODE_EMA, PRICE_CLOSE);
     
     if (!bolcreate || !macreate || !bolcreate_two || !macreate_two)
     {
     Print("Error creating indicator.");
     return(-3);
     }
     
     _ma_ht.AddToChart(1,0);
     bol_bands_ht.AddToChart(1,0);
     _ma_lt.AddToChart(0,0);
     bol_bands_lt.AddToChart(0,0);

//--- succeed
   return(INIT_SUCCEEDED);
  }
JD4
1101
JD4  
Check this page and this page out.  You can tell the program to let you know what failed.
To add comments, please log in or register