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.
So my guess is that you don’t have access to the EA code. If you do, then @gstarmore1s '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.
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.
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.
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?
I mean doing that from another code, indocator probably.
Indicator doesn’t indicate anything, just measuring spread.
Make two templates, one with indicator and expert, other only indicator. If spread too big indicator applies the second template, when spread back to normal it applies the first one.
You might be able to make a template where expert has different settings (entries not allowed). It’s a better choice as expert will be able to handle already opened positions.
It’s not as stupid as it looks like if it works, you know.
It’s very simple.
If you don’t have access to the source code, you can not modify it.
You’d have to contact the developer.
more sadly, you posted in mql5 forum
Props to @wshapter1w for giving the actual solution. This is an easy program to fix!