Function to programmatically disable/enable EA or disable live trading?

 

We can globally enable or disable Expert Advisors by clicking the EA button on the toolbar, but is there a way to do it programmtically?  Possibly via a script or even another EA?


Another area I'm looking into is the "Allow live trading" checkbox found within Tools->Options.  Perhaps there is a way to programmatically activate or de-activate this setting in metatrader?


My idea is to have a global disable of EAs every Friday, and then Enabled when the market opens again the next week.  Any help would be appreciated.

 
shulic:

We can globally enable or disable Expert Advisors by clicking the EA button on the toolbar, but is there a way to do it programmtically?  Possibly via a script or even another EA?


Another area I'm looking into is the "Allow live trading" checkbox found within Tools->Options.  Perhaps there is a way to programmatically activate or de-activate this setting in metatrader?


My idea is to have a global disable of EAs every Friday, and then Enabled when the market opens again the next week.  Any help would be appreciated.

Overthinking a bit?


Put this code right after 'int start()'

if(DayOfWeek()==5){return(0);} //the EA will not execute when the dayofweek is friday


 

haha thank you c0d3.  I forgot to explain one more limitation, I am not able to embed new code into this existing EA.  It is not my EA unfortunately, or else I would modify it to my heart's content.  So my thoughts were to create either a new script or EA, or even a DLL of some sort that can turn off this existing EA at a certain time of the day.


Do you know of any way to get around the fact that the EA cannot be modified?  Thanks so much.

 

just passing thots!

is a bit total kill idea - but there are Windows api calls to

ShellExecute(); or WinExec();
and most likely something to nuke Terminal.exe to!

.

a little noddy prcs with timer could terminate and restart ???

 

fbj, I like your idea.  It reminded me of a tool I had long forgotten. AutoIt.

I am going to script an autoit executable to create a custom keystroke macro to remove/disable the EA.

 

shulic, that good then!

i googled AutoIt and found site... NICE (well, yet another bookmark to remember ;) - not need now but never know...

;)

Reason: