algorithmic trading - What is the difference between init() and OnInit()? -


i learning mql4. on reference website, creating custom indicator done follows:

#property indicator_chart_window  int init(){     return(0); }  int deinit(){     objectsdeleteall();     return(0); }  int start(){      return(0);  } 

but when create new indicator inside metaeditor, syntax, this:

int oninit()  {   //--- indicator buffers mapping   //---  return(init_succeeded); } //+------------------------------------------------------------------+ //| custom indicator iteration function                              | //+------------------------------------------------------------------+ int oncalculate(const int rates_total,             const int prev_calculated,             const datetime &time[],             const double &open[],             const double &high[],             const double &low[],             const double &close[],             const long &tick_volume[],             const long &volume[],             const int &spread[])  {  //---  //--- return value of prev_calculated next call return(rates_total); } 

why different?

is there web link, or book can refer me to? read best place mql4 website, looks different , not sure turn now.

any appreciated. in advance.

where observed difference comes from?

an mql4 language has moved ( somewhere metatrader4 terminal liveupdate release build 572 .. 6xx ) "half-step" towards generation of metaquotes programming language ( named mql5 ).

while mql4 language has spanned many years , mature , stable, both in concept , execution, "new"-mql4 introduces things, "traditional" mql4 language ( , code-execution environment ) not ready use.

so, observation have made, right due "old"-syntax code snippets residing on many web pages , "new"-syntax, pasted inside blank/new indicator template "new"-mql4-ide.

what in practice?

your "new"-syntax work on post-build-572+ metatrader4 terminals. need not worry "incompatible" case, "new" code colliding "old"-terminal, metatrader4 server has internal setting, dictates "oldest"-allowed terminal server willing allow connect , serve. matter of fact, means newer able connect / run pre-build-572 metatrader4 terminal connected broker side, "new"-code collide "old"-syntax rules.

anyway, sake of mql4 syntax disambiguation, there compiler directive available:

#property strict             // read mql4-ide file more details 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -