EA turned on by script

 
Hello. Is it possible to activate EA through script? Basic idea is: EA is active (or just present on chart) with the spread below some value only. If it's higher then script turns off EA and bring it back when spread falls to desired level. Any examples of such solution? Regards
 
Forgot to mention - applies to MT4.
 
Not by a script but you can just code a spread filter directly into the EA.
 
slav:
Hello. Is it possible to activate EA through script? Basic idea is: EA is active (or just present on chart) with the spread below some value only. If it's higher then script turns off EA and bring it back when spread falls to desired level. Any examples of such solution? Regards

So my guess is that you don't have access to the EA code. If you do, then go with @Marco vd Heijden 's solution.

If you don't, then you might be able to do something with Windows DLL calls to programmatically toggle the AutoTrading button. As for how that is done, I couldn't say because I have never done it myself.

Start here: https://www.mql5.com/en/forum/151395

How to Disable / Enable Expert programmably ?
How to Disable / Enable Expert programmably ?
  • 2014.05.01
  • www.mql5.com
Hello I want to Disable / Enable Expert (Auto Trading) button programmably as if i click on it to enable or disable Expert according to condition...
 
Anthony Garot:

So my guess is that you don't have access to the EA code. If you do, then go with @Marco vd Heijden 's solution.

If you don't, then you might be able to do something with Windows DLL calls to programmatically toggle the AutoTrading button. As for how that is done, I couldn't say because I have never done it myself.

Start here: https://www.mql5.com/en/forum/151395

Anthony, you've got the point. If so, is there any global parameter like "trading allowed" so I can disable it if spread is higher then demanded (maybe with another EA pinned to the same chart) thus my proper trading EA is unable to open any position?

 
You can remove the expert and add it back when spread is OK.
 
Expert
Expert
  • www.mql5.com
All other files on this page provide examples/scenarios of library application; they are not needed for the operation of the library. Features Example The library use examples/scenarios are attached to the description. ExpertsRemove.mq5 ExpertsReopen.mq5 ChartsClose.mq5 ExpertLoader_Example.mq5 ExpertsChange_Example.mq5 The above examples...
 
kypa:
You can remove the expert and add it back when spread is OK.

That's not what "automated trading" is intended for...

 
slav:

That's not what "automated trading" is intended for...

Do you also turn on and off the television set by plugging it in and out of the wall socket ?

You create an EA and you code it to do whatever you want it to do if that means not trade when spread is high you add a rule for that in the code.

You do not write another EA or script that controls the first one, it is unnecessary and a complicated way to achieve what you need. 

 
Marco vd Heijden:

Do you also turn on and off the television set by plugging it in and out of the wall socket ?

You create an EA and you code it to do whatever you want it to do if that means not trade when spread is high you add a rule for that in the code.

You do not write another EA or script that controls the first one, it is unnecessary and a complicated way to achieve what you need. 

If you have read the thread from the beginning, you would conclude that I dont have access to EA's source...

 
slav:

If you have read the thread from the beginning, you would conclude that I dont have access to EA's source...

Where in the thread do you state that you don't have the source code?

Reason: