Terminate EA from initialization phase?

 

I working on an DLL authorization module for use with MetaTrader. As my final step, I want this module to only be used when the indicator is applied. I wonder if there is any way to completely shut down the indicator once a conditions is set? If I use "return(0)" in initialization, it will just pass the rest of the code within the {} and continue with the "start" anyway.. I want to completely stop the indicator from running thru the code. (compare it with when DLL's is not allowed, the indicator completely shuts down).

Any suggestions?

Thank you in advance,

Johan

 

Put a conditional return right after start.

 

Thank you for your reply Phy. But if I put a conditional return right after start, then it will check this for every tick... or do I misunderstand you?

Thanks,

Johan

 

'Cannot repeat this: Stringo states: "Divide by zero in the EA stops your EA permanently."'

Only 4 errors stop EA

ERR_CANNOT_LOAD_LIBRARY 4018 At calling of an imported function, loading error of dll or ex4 library occurred
ERR_CANNOT_CALL_FUNCTION 4019 At calling of an imported function, it was found out that dll or ex4 library did not contain the called function
ERR_DLL_CALLS_NOT_ALLOWED 4017 At calling of an imported dll function, it was found out that dll imports were not allowed
ERR_EXTERNAL_CALLS_NOT_ALLOWED 4020 At calling of an ex4 function, it was found out that external ex4 imports were not allowed


ERR_CANNOT_CALL_FUNCTION should help you

 

Thank you for your reply Phy. But if I put a conditional return right after start, then it will check this for every tick... or do I misunderstand you?

Yes, every tick the EA will start, and exit.

 
phy wrote >>

Thank you for your reply Phy. But if I put a conditional return right after start, then it will check this for every tick... or do I misunderstand you?

Yes, every tick the EA will start, and exit.

I solved in kind of the way you described, but with a slight modification. The conditions is tested in the initialization phase, and the return is stored in a global variable. Then, if this global variable is set to a certain value (that is check immediately in the start{}), then it we use return(0). This way it will only use resources once when the EA is applied, but will stop it from running for every new tick.

Thank you for your help guys.

/Johan

Reason: