//--- importing required dll files
#include <WinUser32.mqh>
#import "user32.dll"
int GetAncestor(int, int);
#define MT4_WMCMD_EXPERTS 33020
#import
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void SetAlgoTradingTo(bool trueFalse) {
//--- getting the current status
bool currentStatus = IsTradeAllowed();
//--- if the current status is equal to input trueFalse then, no need to toggle auto-trading
if(currentStatus != trueFalse) {
//--- Toggle Auto-Trading
int main = GetAncestor(WindowHandle(Symbol(), Period()), 2/*GA_ROOT*/);
PostMessageA(main, WM_COMMAND, MT4_WMCMD_EXPERTS, 0 );//Toggle Expert Advisor button
}
}
J
Best posts made by jonatassantanacaje
-
RE: Help - Custom MQL Codeposted in Questions & Answers