Help - Custom MQL Code
-
The bool can be nice to have though if you want to toggle it back on or something with other conditions. Glad you got it to work.
-
Brilliant, thankyou,,
-
@willramsey Thanks for this, it works perfectly, how would you go about making it work for MT5, I tried to simply change the code where it says MT4 to MT5, grasping at straws'
it didn't work
-
For MQL5, this is the code. Unfortunately, there seems to be an error with FXDreema or something for the MQL5 version. You'll have to save it as a MQ5 (the source code) and delete the semicolons on the global variables (includes/defines). For whatever reason when trying to compile, it's putting semicolons which makes it returns an error when trying to compile. I did test it and it works.
// Global Variables, includes #include <WinAPI/winapi.mqh> #include <WinAPI/winuser.mqh> #define MT_WMCMD_EXPERTS 32851 #define WM_COMMAND 0x0111 #define GA_ROOT 2 // Main Code if (TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)){ HANDLE hchart = ChartGetInteger(ChartID(), CHART_WINDOW_HANDLE); HANDLE hmt = GetAncestor(hchart, GA_ROOT); PostMessageW(hmt, WM_COMMAND, MT_WMCMD_EXPERTS, 0); }When you export the MQ5 from FXDreema, you need to remove these semicolons:

Sorry there isn't an easier way, not sure why it's randomly putting semicolons.
-
OK, thats great, thanks again
-
@willramsey
@jonatassantanacaje
@jstap
@sktsecDoes anyone have a similar solution to Disable AlgoTrading on MT5 that doesn't need to use libraries?
-
........
-
@jstap
I wanted to say in the message some solution for MT5 that does not need to use (libraries) and that is (similar) to the MT4 solution where it works to compile directly in Fxdreema without having to generate the .mq5 file and include it manually within the code.
But it's okay if there is no such solution and I'll check if I can make it work and post the solution here for everyone when I find it. -
I have tried it and it works perfectly. Thank you very much!!
-
To round off just in case the good work of the previous ones, if we want to activate it it's the same but adding the '!' to the conditional:
<<Global variables>>
#include <WinAPI/winapi.mqh>
#include <WinAPI/winuser.mqh>
#define MT_WMCMD_EXPERTS 32851
#define WM_COMMAND 0x0111
#define GA_ROOT 2<<Settings>>
if (!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)){HANDLE hchart = ChartGetInteger(ChartID(), CHART_WINDOW_HANDLE); HANDLE hmt = GetAncestor(hchart, GA_ROOT); PostMessageW(hmt, WM_COMMAND, MT_WMCMD_EXPERTS, 0);}