- Replace user32.dll information . Help for Mql Market
- News filter with DLL on mql5?
- How to Disable / Enable Expert programmably ?
Here is a working solution:
// Enable auto-trading button if(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) == 0) Simulate_Ctrl_E(); // Disable auto-trading button if(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) == 1) Simulate_Ctrl_E(); //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #define KEYEVENTF_KEYUP 0x0002 #include <WinAPI\winapi.mqh> #include <VirtualKeys.mqh> //+------------------------------------------------------------------+ //| Simulate 'Ctrl+E' keystroke | //+------------------------------------------------------------------+ // toggle the Automated 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); } //+------------------------------------------------------------------+
Unfortunately, no!
What do you mean "without keyboad"?
The MT4 solutions that I know of also uses simulated keyboard events to enable/disable the Auto Trading button!
What @amrali provided is the MT5 version for the Algo Button, but it uses the same concept as the MT4 solution.
EDIT: Just noticed that there is indeed another solution for MT4 using "MT4_WMCMD_EXPERTS". However, I don't see why you can't use the Key Event method in your case. Can you explain why?
What do you mean "without keyboad"?
The MT4 solutions that I know of also uses simulated keyboard events to enable/disable the Auto Trading button!
What @amrali provided is the MT5 version for the Algo Button, but it uses the same concept as the MT4 solution.
EDIT: Just noticed that there is indeed another solution for MT4 using "MT4_WMCMD_EXPERTS". However, I don't see why you can't use the Key Event method in your case. Can you explain why?
Because key event work on whole windows softwares, for example if expert work on meta trader and user open web browser, when EA call key event, then this key event effect on his browser.
The following solution works on both MT4 and MT5 (This is a Script with conditional compilation for both platforms):
EDIT: This uses the same technique used on MT4 without keyboard events, by using Custom Windows Messaging for MetaTrader.#property strict #ifdef __MQL5__ #include <WinAPI\winapi.mqh> #define MT_WMCMD_EXPERTS 32851 #else #define HANDLE int #define PVOID int #import "user32.dll" HANDLE GetAncestor( HANDLE hwnd, uint flags); int PostMessageW( HANDLE hwnd, uint Msg, PVOID param, PVOID param ); #import #define MT_WMCMD_EXPERTS 33020 #endif #define WM_COMMAND 0x0111 #define GA_ROOT 2 void OnStart() { AlgoTradingStatus( true ); // Enable Algo Trading } void AlgoTradingStatus( bool Enable ) { bool Status = (bool) TerminalInfoInteger( TERMINAL_TRADE_ALLOWED ); if( ( Enable && Status ) || ( !Enable && !Status ) ) return; HANDLE hChart = (HANDLE) ChartGetInteger( ChartID(), CHART_WINDOW_HANDLE ), hMetaTrader = GetAncestor( hChart, GA_ROOT ); PostMessageW(hMetaTrader, WM_COMMAND, MT_WMCMD_EXPERTS, 0 ); }
The following solution works on both MT4 and MT5 (This is a Script with conditional compilation for both platforms):
EDIT: This uses the same technique used on MT4 without keyboard events, by using Custom Windows Messaging for MetaTrader.thank you sir
I tested it as script and expert advisor
and its working perfectly
that is what I needed
its great
thank you sir
I tested it as script and expert advisor
and its working perfectly
that is what I needed
its great
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use