Hijotech2021:
Dear Guys,
I need help to allow EA to disable automatic trading after closing a trade and enable automatic trading at a specified time.
The EA should be able to monitor the trade terminal and once all trade are closed and no trade is open the EA disable the
auto trade and wait for a specified time to enable the auto trade on the MT4 account. This is what i want the EA to perform.
i need help on any code or EA that can do this.
Thanks
//+------------------------------------------------------------------+ //| test disable.mq4 | //| Programmed by Noé Combes-Bardoll | //| https://www.mql5.com/en/users/nono86 | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property strict #define WM_LBUTTONDOWN 0x0201 #define WM_LBUTTONUP 0x0202 #define WM_KEYDOWN 0x0100 #define KEYEVENTF_KEYUP 0x0002 #define WM_COMMAND 0x0111 //#include <WinUser32.mqh> #import "user32.dll" int PostMessageW(int hWnd,int Msg,int wParam,int lParam); int UpdateWindow(int hWnd); int GetAncestor(int,int); int GetDlgItem(int hDlg,int nIDDlgItem); int GetWindowTextLengthA (int hWnd); int GetWindowTextA(int hWnd,char &lpString[],int nMaxCount); int PostMessageA(int hWnd,int Msg,int wParam,int lParam); int GetLastActivePopup(int hWndOwner); int GetWindow(int hWnd, int uCmd); int GetParent(int hWnd); void keybd_event(int bVk,int bScan,int dwFlags,int dwExtraInfo); int SendMessageA(int hWnd,int Msg,int wParam,int lParam); #import int start(){ int hMetaTrader = GetAncestor(WindowHandle(Symbol(),Period()),2); PostMessageA (hMetaTrader, WM_COMMAND , 33048, 0); Sleep(200); int kid=get(hMetaTrader); string top=name(kid); if(top=="Common "){ kid=avance(kid); int is_checked=check_state(kid); if(is_checked){Print("button is currently checked");Comment("EA is now [OFF]");} else{Print("button is currently NOT checked"); Comment("EA is now [ON]");} PostMessageW(kid,WM_LBUTTONDOWN,1,0); Sleep(10); PostMessageW(kid,WM_LBUTTONUP,1,0); Sleep(10); PostMessageA(kid,WM_KEYDOWN,0x0D,0); return 0; } else if(top==""){ 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{ 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); } Sleep(100); kid=get(hMetaTrader); kid=avance(kid); Sleep(100); bool is_checked=check_state(kid); if(is_checked){Print("button is currently checked");Comment("EA is now [OFF]");} else{Print("button is currently NOT checked"); Comment("EA is now [ON]");} PostMessageW(kid,WM_LBUTTONDOWN,1,0); Sleep(10); PostMessageW(kid,WM_LBUTTONUP,1,0); Sleep(10); PostMessageA(kid,WM_KEYDOWN,0x0D,0); return 0; } int get(int basic){ UpdateWindow(basic); int hInner = GetLastActivePopup(basic); int popup=GetWindow(hInner,5); int kid=GetWindow(popup,5); return kid; } int avance(int kid){ Sleep(10); kid=GetWindow(kid,2); kid=GetWindow(kid,2); kid=GetWindow(kid,2); kid=GetWindow(kid,2); kid=GetWindow(kid,2); kid=GetWindow(kid,2); Sleep(10); return kid; } bool check_state(int handle){ return (bool)SendMessageA(handle, 0x00F0, 0, 0); } string name(int handle){ char e[]; StringToCharArray("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234",e) ; //string p1; GetWindowTextA(handle,e,GetWindowTextLengthA(handle)+1); return CharArrayToString(e); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Dear Guys,
I need help to allow EA to disable automatic trading after closing a trade and enable automatic trading at a specified time.
The EA should be able to monitor the trade terminal and once all trade are closed and no trade is open the EA disable the
auto trade and wait for a specified time to enable the auto trade on the MT4 account. This is what i want the EA to perform.
i need help on any code or EA that can do this.
Thanks