Is it possible to create an indicator or an expert to turn off Auto Trading on Meta Trader 5?

 

Hi Everyone!

Do you know if it is possible to create an indicator or expert or anything else that would disable an expert advisor operating on a Meta Trader 5 chart under certain conditions?

This is the request/scenario.  I am running an Expert Advisor on a chart.  Some time later a Bill Williams Reversal Fractal appears on chart.  Ideally I would like the Expert Advisor to be removed preventing new trades from being opened. Is this even possible?

This scenario is ideal but I am also open to the idea that this might not be possible so the other question is can auto trading be disabled entirely rather than just on the current chart?

Appreciate any input regarding this.

Kind regards, Shane

 
Shane McDonald:

Hi Everyone!

Do you know if it is possible to create an indicator or expert or anything else that would disable an expert advisor operating on a Meta Trader 5 chart under certain conditions?

This is the request/scenario.  I am running an Expert Advisor on a chart.  Some time later a Bill Williams Reversal Fractal appears on chart.  Ideally I would like the Expert Advisor to be removed preventing new trades from being opened. Is this even possible?

This scenario is ideal but I am also open to the idea that this might not be possible so the other question is can auto trading be disabled entirely rather than just on the current chart?

Appreciate any input regarding this.

Kind regards, Shane

You can read this link

Disallowing multiple EA instances in one terminal
Disallowing multiple EA instances in one terminal
  • 2011.01.04
  • www.mql5.com
Hi, can anyone think of a way to disallow the user to run more than 1 instance of the same EA in one MT4 terminal at once (not only 2 forward testi...
 
Yes, I used this in the past with a custom EA I had. The programmer put a "Start" "Stop" button on the chart that turned off the entry into new position for XX number of bars. Another time the pause buttons were configured in a standard number of seconds (a function in MT4 at the time).  I like the number of bars options better because it was more suited to different time frames of different instruments.  You can get a freelancer to do this kind of coding for you.  I am not a coder, only a trader.
 

Thank you guys for the reply I appreciate it!

I am looking for though complete automation of this manual process shown in the image attached.

It needs to have basic conditions attached to this also as described in my original post.

I am not looking to run more than one EA, just want to be able to close the one that i running automatically when conditions happen.

Files:
 
 
Shane McDonald:

Hi Everyone!

Do you know if it is possible to create an indicator or expert or anything else that would disable an expert advisor operating on a Meta Trader 5 chart under certain conditions?

This is the request/scenario.  I am running an Expert Advisor on a chart.  Some time later a Bill Williams Reversal Fractal appears on chart.  Ideally I would like the Expert Advisor to be removed preventing new trades from being opened. Is this even possible?

This scenario is ideal but I am also open to the idea that this might not be possible so the other question is can auto trading be disabled entirely rather than just on the current chart?

Appreciate any input regarding this.

Kind regards, Shane

Why not have the current expert your are using coded to detect such scenario and will be automatically paused (no trading but not removed from chart) while bill Williams conditions are true....of course this is only possible if you have the expert adviser source code. Well just another thought...

 

Here is a demo script to show how to control the AutoTrading button programatically.

//+------------------------------------------------------------------+
//|                                                  AutoTrading.mq5 |
//|                                        Copyright © 2018, Amr Ali |
//|                             https://www.mql5.com/en/users/amrali |
//+------------------------------------------------------------------+
#property script_show_inputs
//--- input parameters
input bool  InpEnableAutoButton  = false;   // Enable AutoTrading Button
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
#define KEYEVENTF_KEYUP    0x0002
#include <WinAPI\winapi.mqh>
#include <VirtualKeys.mqh>
//+------------------------------------------------------------------+
//| script start function                                            |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- disable the 'auto-trading' button
   if(!InpEnableAutoButton && TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
     {
      Simulate_Ctrl_E();
     }
  }
//--- enable the 'auto-trading' button
   if(InpEnableAutoButton && !TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
     {
      Simulate_Ctrl_E();
     }
  }     
//+------------------------------------------------------------------+
//| Simulate 'Ctrl+E' keystroke to toggle the 'auto-trading' button  |
//+------------------------------------------------------------------+
void Simulate_Ctrl_E()
  {
   keybd_event(VK_CONTROL,0x9d,0,0);
   keybd_event((uchar)VkKeyScanW('E'),0x92,0,0);
   keybd_event((uchar)VkKeyScanW('E'),0x92,KEYEVENTF_KEYUP,0);
   keybd_event(VK_CONTROL,0x9d,KEYEVENTF_KEYUP,0);
  }
//+------------------------------------------------------------------+
Files:
 

ExpertRemove

The function stops an Expert Advisor and unloads it from a chart.

     https://www.mql5.com/en/docs/common/expertremove


//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 
   if(floating_profit<-1000)
     {
      Alert("The expert advisor will be unloaded");
      ExpertRemove();
     }
  }
Documentation on MQL5: Common Functions / ExpertRemove
Documentation on MQL5: Common Functions / ExpertRemove
  • www.mql5.com
//|                                            Test_ExpertRemove.mq5 | //|                        Copyright 2009, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | //| Expert deinitialization function                                 |...
 

Thanks all for the suggestions.

The EA is purchased as is from the vendor.

I could approach them and ask for a personal project but they may not be keen on altering their code as a one off task.

I was hoping I might be able to run something separately to the EA, keeping in mind this is not changing the EA it is only stopping it from continuing.

 
Why don't u use variables and do trading within the expert ?
 
It's not possible to turn off the Autotrader button by an expert. Especially couldn't you turn it on. It's mutual exclusive...

But you can create an EA or a service to load a template onto a chart which you also can open with an EA, including the EA you want to run. And you can close the chart including the EA you want to turn off.