Is it possible to enable/disable an EA with a script or another EA?

 

My problem is that I have some EA's that I do not have the mq4 file for. They work very well when the market is trending but VERY bad when it is not. I would like to be able to enable/disable the EA's based on the angle of a moving average. I would also need to be able to close any open or pending orders automatically when the EA is disabled. Is there any way to do this?

Thanks.

 
Easy, talk to the people that wrote and own the EAs and ask them to do the modifications.
 

And if they are not willing to do the modifications?

 
sothirsty:

And if they are not willing to do the modifications?

You might be able to write or get written an EA that closes particular charts and then closes any relevant Orders, closing the orders is the easy bit . . .
 
sothirsty:

I would like to be able to enable/disable the EA's based on the angle of a moving average.

I would also need to be able to close any open or pending orders automatically when the EA is disabled.

  1. Then You must remove the EA or close the chart window, either manually or programmatically. REF
    #define MT4_WMCMD_REMOVE_EXPERT 33050 /* Remove expert advisor from chart */
    #define MT4_WMCMD_CLOSE_CHART   57602 /* close the current chart */
    #include <WinUser32.mqh>
    :
    int hwnd = WindowHandle(Symbol(), Period());
    if (hwnd == 0){
        Alert("No such window ", Symbol(), " ", Period());
    else if (!IsDllsAllowed()) {         //DLL calls must be allowed
        Alert("Dll calls must be allowed");
    else if (PostMessageA(hwnd, WM_COMMAND, MT4_WMCMD_REMOVE_EXPERT, 0) == 0)
        Alert("PostMessage failed");
  2. You know the EAs magic number so you can close them.
        for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol()                 // and my pair.
        ){
            if (OrderType() > OP_SELL){
                 if (!OrderDelete(OrderTicket()) 
                    Alert...
            }
            else if (!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 30)
                Alert...
         }
  3. You must manually reattach the EA when desired.
 

So there is no way to turn live trading of an EA on/off based on an indicator?

 

of course there is (but not easy, involving WINAPI)

Reason: