Is there a way to compile MQL4 and/or MQL5 files within command line?

 

Is there a way to compile MQL4 and/or MQL5 files within command line?

 

metaeditor.exe /compile "the mql file"

or something like that

metaeditor64.exe for 64 bit MT5

 
Jose Luis Lominchar:

Is there a way to compile MQL4 and/or MQL5 files within command line?

Here's a simple batch file I use.
@echo off

    set METAEDITOR="C:\Program Files\MetaTrader 5\metaeditor64.exe"
    set "LOGFILE=%~dpn1.log"

    if "%~1"=="" (
        echo "You must specify the first parameter to this batch file."
        goto end
    )

    :: Compile the MQL5 way
    %METAEDITOR% /compile:%1 /log
    :: 0 = failed
    :: 1 = everything good
    echo "Error level %ERRORLEVEL%"

    :: This dumps the log file to stdout so it can be seen.
    :: It's assumed to be in the same directory as the expert file.
    type "%LOGFILE%"

    :: Once shown, get rid of the .log file.
    erase "%LOGFILE%"    

:end
    :: If I want the CMD.exe window to go away, use exit
    ::exit %ERRORLEVEL%
 
Thank you very much, Anthony. I'll try it.
 

Hey guys,

Where do i put the ml5 file path in this batch file?

 
Anthony Garot #:
Here's a simple batch file I use.
How to use this code?
 
LordFarshad #: How to use this code?

It's not really code. It's Windows command line instructions in a text batch file, usually with the extension ".cmd" or ".bat". It is run from the command line.

 
Anthony Garot #:
Here's a simple batch file I use.

Handy script - thanks!

Reason: