Another Elementary Inquiry on EA Codes

 
Hi.

I would like to ask the following:

1. Init - does something that you want the EA to do as it is loaded in the chart. If that is so, why does this not prompt the Hello world upon load of the EA?
int OnInit()
  {
   return(INIT_SUCCEEDED);
   Print("Hello World");   
  }

- Why do the following errors show?

// This:
void OnInit();
//or
void Init();
//gives the error message: '{' - function definition unexpected


// while this:
void OnInit()
//or
void Init()
//gives the error message: 'return' - 'void' function returns a value

- Is the Init/OnInit part of the code optional?

- Is Init same as OnInit? If no, how are they different? I read that Init is for MQL4 and OnInit is for MQL5. Is there any difference other than the syntax?

2. Deinit - shows an error message why the EA failed. I was unable to test it but is this correct?

- Is Deinit same as OnDeinit? as stated above.

- I read that void classes do not return any value. But why does void Deinit (); return the reason for deinitialization?

3. Start - It is said that this is for scripts and not EA. https://docs.mql4.com/runtime/event_fire#start however, it works fine in my EA. Furthermore, a certain EA generator website uses this Start function as a default command which encompasses all OpenBuy, OpenSell, etc orders. Can anyone clarify this?

4. OnTick - It seems to work fine, in the same precise way Start works. But sometimes, Start works but OnTick fails. How can that be? How are the 2 different? The only distinction between them is as said by the abovementioned site, but in my test case it does not seem to be the case.

5. Print - when must the "void" class be included in the code, as the mql4 guide has mentioned in the examples? My experience shows that sometimes it requires the void portion. At times it does not. Is this discrepancy due to the Print() function or the void class? If so, what might that be?

These will be all for now.

I thank you in advance for your patience. Your guidance is very much appreciated. :)


=====

P.S. This is a repost from another thread, which has quite strayed from my original question (which I has gone too deep for my understanding for now). I would really love a help on this nagging matter. @_@
 
Ibex Thales:
Hi.

I would like to ask the following:

1. Init - does something that you want the EA to do as it is loaded in the chart. If that is so, why does this not prompt the Hello world upon load of the EA?

int OnInit()
  {
   return(INIT_SUCCEEDED);
   Print("Hello World");   
  }


Try

int OnInit()
  {
   Print("Hello World"); 
   return(INIT_SUCCEEDED);  
  }
 
Keith Watford:

Try

I see. Will try that in a while.

But I also want to ask the difference of start vs OnTick. Guides and boards say OnTick is for EA while start is for custom indicators, but as I tried, OnTick wont work while start can. Do I need to append some kind of command somewhere?
 

When you want to start a new project, click on "New" towards the top and left in the editor. Then click on "Indicator" or "Expert"  and complete each stage. Then you will have the new template for coding which will include the recent options, OnTick or OnCalculate. It will also use Property Strict which everybody should be using nowadays.  

 
Keith Watford:

When you want to start a new project, click on "New" towards the top and left in the editor. Then click on "Indicator" or "Expert"  and complete each stage. Then you will have the new template for coding which will include the recent options, OnTick or OnCalculate. It will also use Property Strict which everybody should be using nowadays.  

But sometimes, the OnTick causes errors while the start works flawlessly. 

I only used class void on both of them. Could I have missed some necessary detail prior to using either of them?
 
Ibex Thales:
But sometimes, the OnTick causes errors while the start works flawlessly. 

I only used class void on both of them. Could I have missed some necessary detail prior to using either of them?

It is extremely doubtful that OnTick would cause errors that you would not get with start.

It is more likely that it is Property Strict that will give errors/warnings because the coding is not following strict procedures. Be thankful for that as it will force you to improve your coding.

Reason: