Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

Libraries

Disable auto trading but ONLY for a specific EA - library for MetaTrader 4

Noe Combes Bardoll | English Español Português 日本語 Deutsch

Views:
823
Rating:
votes: 5
Published:
2020.05.02 16:53
\MQL4\Scripts\\MQL4\Include\
WinUser32.mqh (37.64 KB)view

This script is made to disable the EA on the chart from trading, Its made to click the following buton on the image, automatically :

In the following code, its getting the handle of the main Metatrader and open the Expert tab (command 33048 is in mt4, for mt5 It's different)

int hMetaTrader = GetAncestor(WindowHandle(Symbol(),Period()),2);         
   
PostMessageA (hMetaTrader, WM_COMMAND , 33048, 0);

Sleep(200); //It's important to keep at least 0.2 secs to let the window open correctly 

Then we need to check what tab we are currently on, we get the name of the tab and auto correct to go to the right one :

int kid=get(hMetaTrader);
   
   string top=name(kid);
   
   if(top=="Common "){//if the window is already the right one (Common section tab), just find the button, click it and click OK
      kid=avance(kid);
      
      int is_checked=check_state(kid);
      
      if(is_checked){Print("button is currently checked");}
      else{Print("button is currently NOT checked");}
      
      Sleep(10);
      PostMessageW(kid,WM_LBUTTONDOWN,1,0);//press the left mouse button
      Sleep(10);
      PostMessageW(kid,WM_LBUTTONUP ,1,0);//release it
      Sleep(10);
      PostMessageA(kid,WM_KEYDOWN,0x0D,0);//pressing enter to validate the selection
      return 0;
      
      }
   else if(top==""){//if the tab is the "About" section, press ctrl+tab (to go 1 tab forward)
      Print("first");
      Sleep(10);
      keybd_event(17,0,0,0);
      Sleep(10);
      keybd_event(9,0,0,0);
      Sleep(10);
      keybd_event(9,0,KEYEVENTF_KEYUP,0);
      Sleep(10);
      keybd_event(17,0,KEYEVENTF_KEYUP,0);
      Sleep(10);
      }
   else{//if the tab is "Inputs" then press ctrl+maj+tab (to go 1 tab back)
      keybd_event(17,0,0,0);
      Sleep(10);
      keybd_event(16,0,0,0);
      Sleep(10);
      keybd_event(9,0,0,0);
      Sleep(10);
      keybd_event(9,0,KEYEVENTF_KEYUP,0);
      Sleep(10);
      keybd_event(16,0,KEYEVENTF_KEYUP,0);
      Sleep(10);
      keybd_event(17,0,KEYEVENTF_KEYUP,0);
      Sleep(10);
      }

And then finally if the tab wasn't the right one, find the button "allow auto trading" and press it to disable it :

   Sleep(100);
   kid=get(hMetaTrader);
   kid=avance(kid);
   Sleep(100);
   bool is_checked=check_state(kid);

   if(is_checked){Print("button is currently checked");}
   else{Print("button is currently NOT checked");}
   
   Print(name(kid));
   PostMessageW(kid,WM_LBUTTONDOWN,1,0);
   Sleep(10);
   PostMessageW(kid,WM_LBUTTONUP,1,0);
   Sleep(10);
   PostMessageA(kid,WM_KEYDOWN,0x0D,0);


I forgot to mention that the code is going to click this particular button even if the autotrading is already off so Its going to activate it, disable it, activate it.. Thats why I made a special function to get the current state of the button, you can modify the code as you want to change it getting the button state with this function :

int kid=<HANDLE OF THE BUTTON>
bool is_checked=check_state(kid);

bool check_state(int handle){
   return (bool)SendMessageA(handle, 0x00F0, 0, 0);
   }


Smoothed Bar to Bar Correlation Smoothed Bar to Bar Correlation

The Correlation Indicator provides a smoothed bar to bar correlation value.

MA HISTOGRAM SEPARATE WINDOW MA HISTOGRAM SEPARATE WINDOW

Trend indicator (separate window)

RingSystemEA RingSystemEA

It's a triangular arbitrage system (three pairs correlation system) to use 3 currencies to make 3 pairs to open hedge orders on those. The expert starts opening six orders for each ring (3 plus and 3 minus) and waits to move prices in one direction to make a grid of orders.

MACD With All Parameters MACD With All Parameters

Standart MACD Indicator but All Parameters like as FastMA, SlowMA and SignalMA parameters can be changed