Do the Return values of special functions mean anything?

 

Hi guys,

Just a quick one.....when the special functions(init, start & uninit) are called, they return an integer value. Is this value usable in any form.......

As an example, I usually add a line in the init function :-

if (Period() != 15){
   Alert("Wrong timeframe!");
   return(-1);
}
I would have thought that perhaps return a figure like -1 could tell MT4 that the init() function has encountered an error and I do not want the EA to continue running. I do have a routine that will remove the EA from the chart but that seems a bit extreme.

Also I know that I could place the same line of code in the start() function and it would effectively de-activate the EA, however, in the interest of efficient coding I would prefer the EA not to have run lines of code that could be done once in the init function, after all thats why it is there.

Any comments?
 
The return value seems to have no meaning. You should just set your own flag and check for that flag in the start() function.

If you really want to do an ugly hack you can try to import and call a non existing function in a dll, this will trigger an error that will make the EA completely stop until it is re-initialized, but the error message in the log will confuse the users. Better just set a flag and check this at the very beginning of the start() function.
 

7bit, thanks for the reply mate.........

I had feared as much......seems kind of pointless having it return an integer value. Should have been a void function instead. Anyway, I have a pretty nifty DLL call that simply removes the EA from the chart altogether if there is an init error I don't like. Just seems extreme when you simply want the user to change the timeframe.

I also seem to have developed a fetish for ultra efficient code(I don't delude myself into thinking I'm there but reaching for the stars and all that good stuff, you know).............and that means not wasting time repeatedly doing tasks that the init function should have taken care of.

 
kennyhubbard wrote >>

Hi guys,

Just a quick one.....when the special functions(init, start & uninit) are called, they return an integer value. Is this value usable in any form.......

As an example, I usually add a line in the init function :-

I would have thought that perhaps return a figure like -1 could tell MT4 that the init() function has encountered an error and I do not want the EA to continue running. I do have a routine that will remove the EA from the chart but that seems a bit extreme.

Also I know that I could place the same line of code in the start() function and it would effectively de-activate the EA, however, in the interest of efficient coding I would prefer the EA not to have run lines of code that could be done once in the init function, after all thats why it is there.

Any comments?


Hi,

What is the difference if start() is ended with return; or return(0) or return(-1)? Where does these values go to?