How to compile MQL code using console/terminal commands?

Is there any console command that can compile the mq5 file? For example:

“mql5 -compile ./strategy101.mq5 ./strategy101.ex5”

If so, I can use other code editors such as sublime text for development by setting a build environment.

The default MetaEditor cannot fold the code and it is already becoming a problem to go back and forth in one large file containing many event handlers.

Console compiler MQL4/MQL5 stayed updated with the platform MetaTrader 4/5 and is always available on the links:

DLL files are no longer needed him.

Very cool! Thanks!..

I tried compiling MQL4 from command line and I have found this: https://www.metatrader5.com/en/metaeditor/help/development/compile

You have the metaeditor.exe or metaeditor64.exe which can compile code with /compile:file.mq4 or /compile:file.mq5 and even include your own includes with /inc:[includes directory] , write the output into a file with /log:file.txt and so on.

For Sublime text 3 I use the following build script (in case anyone needs it as an example), which includes opening help files:


{
	"variants": [
		{
			"name": "Compile Expert",
			"cmd": [
				"C:\\Program Files (x86)\\SimpleFX MetaTrader 4 Terminal\\metaeditor.exe",
				"/compile:$file",
				"/log:${project_path:${folder}\\\\${file_base_name}}.log",
				"/inc:$folder\\Personal\\alexandru.chiri\\MQL4",
				"&",
				"type",
				"${project_path:${folder}\\\\${file_base_name}}.log",
				"&",
				"del",
				"${project_path:${folder}\\\\${file_base_name}}.log",
				"&",
				"echo",
				"Deploy ex4 to Experts:",
				"&",
				"copy",
				"${file_base_name}.ex4",
				"%appdata%\\MetaQuotes\\Terminal\\E5A4E68F1B7E15DF3B06ED6AF0EC4859\\MQL4\\Experts\\",
				"&",
				"del",
				"${file_base_name}.ex4",
				],
			"shell": true
		},
		{
			"name": "Compile Indicator",
			"cmd": [
				"C:\\Program Files (x86)\\SimpleFX MetaTrader 4 Terminal\\metaeditor.exe",
				"/compile:$file",
				"/log:${project_path:${folder}\\\\${file_base_name}}.log",
				"/inc:$folder\\Personal\\alexandru.chiri\\MQL4",
				"&",
				"type",
				"${project_path:${folder}\\\\${file_base_name}}.log",
				"&",
				"del",
				"${project_path:${folder}\\\\${file_base_name}}.log",
				"&",
				"echo",
				"Deploy ex4 to Indicators:",
				"&",
				"copy",
				"${file_base_name}.ex4",
				"%appdata%\\MetaQuotes\\Terminal\\E5A4E68F1B7E15DF3B06ED6AF0EC4859\\MQL4\\Indicators\\",
				"&",
				"del",
				"${file_base_name}.ex4",
				],
			"shell": true
		},
		{
			"name": "Compile Script",
			"cmd": [
				"C:\\Program Files (x86)\\SimpleFX MetaTrader 4 Terminal\\metaeditor.exe",
				"/compile:$file",
				"/log:${project_path:${folder}\\\\${file_base_name}}.log",
				"/inc:$folder\\Personal\\alexandru.chiri\\MQL4",
				"&",
				"type",
				"${project_path:${folder}\\\\${file_base_name}}.log",
				"&",
				"del",
				"${project_path:${folder}\\\\${file_base_name}}.log",
				"&",
				"echo",
				"Deploy ex4 to Scripts:",
				"&",
				"copy",
				"${file_base_name}.ex4",
				"%appdata%\\MetaQuotes\\Terminal\\E5A4E68F1B7E15DF3B06ED6AF0EC4859\\MQL4\\Scripts\\",
				"&",
				"del",
				"${file_base_name}.ex4",
				],
			"shell": true
		},
		{
			"name": "MetaTrader 4 Help",
			"cmd": [
                "start",
                "",
				"hh.exe",
				"%appdata%\\MetaQuotes\\Terminal\\Help\\mql4.chm"
			],
            "shell": true
		},
		{
			"name": "MetaTrader 5 Help",
			"cmd": [
                "start",
                "",
				"hh.exe",
				"%appdata%\\MetaQuotes\\Terminal\\Help\\mql5.chm"
			],
            "shell": true
		}
	]
 }