How to reload command line compiled scripts in Trading Terminal?

When I use Meta Editor IDE, as soon as compilation finishes, the scripts gets removed / reloaded immediately in Trading Terminal.

How can I achieve the same behaviour (reload / reinit scripts), when using command line compilation ?

I can nicely compile the scripts using command line compilation, but I have to refresh the scripts manually each time. I can’t really iterate fast without update automatically.

This is a good question.

I have found this myself since I prefer to work in a different editor than MetaEditor.

What I do:

  1. I keep MetaEditor open on my right-monitor.

  2. I edit using a different editor on the left-monitor.

  3. Changes in the different editor are automatically detected by MetaEditor.

  4. So, when it’s time to compile, I simply click the compile button in MetaEditor, even though I have done no actual editing there.

Thanks for getting back. I did the same for a while (using VSCode, and compile for warnings / errors via command line), however, it can get pretty tedious when compiling too often, e.g. fiddling with some UI thing.

Perhaps there is a way to tell the Terminal to do the refresh thing. I’m wondering how MetaEditor and Terminal is wired up. I did not found any intermediate file that changes. Also, I did not found any mach message, or similar.

As a workaround, I can create a watcher script that polls the modification date for a given mql, then remove / readd a given script to a chart if anything changed. However, the input parameters must be preserved somehow for the indicators. Sounds a lot of upfront work, I’m not quite sure if it is worth it.

This is actually a terribly grumpy workaround, but I use cliclick to programatically invoke a click on MetaEditor Compile button from my build script.

It breaks whenever I move windows around and all, but for now it saves the day.

cliclick (short for “Command Line Interface Click”) is a tool for executing mouse- and keyboard-related actions from the shell/Terminal. It is written in Objective-C and runs on OS X 10.9 or later. Usage To get a quick first impression, this is what you will get when you invoke : Limitations It is not possible to use cliclick before a user logs…

You can either use a AutoHotkey script called after your compile script finished successfully, or you can write a little helper .exe and send a Windows messages to the terminal, again after your compile script finished successfully. That’s

#define WM_COMMAND       0x0111
#define MT4_MQL_REFRESH   12349        // rescan und reload modified .ex4 files

int hWnd = GetTerminalMainWindow();
PostMessage(hWnd, WM_COMMAND, MT4_MQL_REFRESH, 0);


The issue here is to find the Windows handle of the application main window. At the command line you may have multiple terminals open and then you don’t know which terminal to refresh. Either way with multiple installations you should organize your code in a way that all installations use the same MQL code base (e.g. by using symlinks).

In your own tool you can use logic similar to:

You can’t use the function in the compiled DLL ( directly from CLI because it assumes to be called from MQL. You could adapt the code and could send the message to all open terminals (for example).


Sounds pretty exactly what I’m looking for.

The constant (and the window lookup) says MT4. Does it work with MT5 as well?