int init() old way in new 600++ is it losing its values ??

 

This is what i saw

EA on chart

Closed its trades and had to restart new trades

but error from EA '2014.03.11 11:12:28.713 zero divide in 'robodo4.8.mq4' (713,56)' (Build 600)

the moment EA was attached to chart

double Lot = 0.2;
double MinLot,LotStep,StopLevel;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 
   MinLot = MarketInfo(Symbol(), MODE_MINLOT);
   LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
   MaxLot = MarketInfo(Symbol(), MODE_MAXLOT); 
   Stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL);
   if(Lot < MinLot)Lot = MinLot;

   return(0);
  }

function at line 713

//+------------------------------------------------------------------+ 
//--- Function test of the correctness and rounding --- 15 ---//
double LotRound(double L) {
 return( MathRound(MathMin(MathMax(L, MinLot), MaxLot)/LotStep)*LotStep ); }
//+------------------------------------------------------------------+

my question do i need to replace all int init() in newbuild for int OnInit()

avoiding this happens ??

 
deVries:

This is what i saw

EA on chart

Closed its trades and had to restart new trades

but error from EA '2014.03.11 11:12:28.713 zero divide in 'robodo4.8.mq4' (713,56)' (Build 600)

the moment EA was attached to chart

function at line 713

my question do i need to replace all int init() in newbuild for int OnInit()

avoiding this happens ??

Actually not.

Is this problem arises also with build 610 or 616 ?

 
angevoyageur:

Actually not.

Is this problem arises also with build 610 or 616 ?




can't tell the testingdemo's i'm using are 3 times 600 1 time 604

and it takes time to see it happen because it has to appear at live trading

i am using it to find bugs i can't find testing EA's on StrategyTester

 

since build 600 sometimes init not executed well

so from now i always add some code.. if init failed.. init again

int dg=0;
double pt;
void  init()
  {      pt=Point; dg=1;
  if (Digits==3||Digits==5){pt=10*Point;dg=10;}
  }
//+------------------------------------------------------ 

int start()
  { if (dg==0){init();return(0);}


  }
//---- 
 
WDholic:

since build 600 sometimes init not executed well

so from now i always add some code.. if init failed.. init again


Thanks, so i'm not the only one noticed there was something strange on init()

nice solution to workaround this error.

 

I havent noticed anything like that with indicators. I've been working mostly with indicators since build 600 due to a project I'm working on, if init() was not executed indicators would fail due to lack of buffers.