Running Strategy Tester from Batch File

 
Hey all,  

I wonder if anyone can help me. I am trying to launch MetaTrader 5 using a batch file and then loading a custom ini file that I have created using the information on the https://www.metatrader5.com/en/terminal/help/start_advanced/start#command_line page.

This is the current information inside my bat file:
"C:/Program Files/MetaTrader5ICM\terminal64.exe" /config:"pktestdata.ini"

I have then created the following ini file:
; c1.4.0.0u1.4.0.0d3
; C:\Program Files\MetaTrader5ICM\terminal64.exe
; C:\Program Files\MetaTrader5ICM
    
[Tester]
Expert=POW_BANKER_EA_8.32.ex5
ExpertParameters=T&R NEW v8.34.set
Symbol=EURCHF
Period=M1
Model=4
ExecutionMode=100
Optimization=2
OptimizationCriterion=6
FromDate=2023.11.10
ToDate=2023.06.30
ForwardMode=3
ForwardDate=2023.08.02
Report=powkicker\EURCHF
ReplaceReport=0
ShutdownTerminal=1
Deposit=100000
Currency=USD
Leverage=1:100
Visual=0
ProfitInPips=0
; *** Login=
; *** UseLocal=
; *** UseRemote=
; *** UseCloud=
; *** Port=
; *** Dates=3
I have tried saving this ini file as both UTF-8 format and UTF-16 to see if this would help with MetaTrader accepting the file but so far no luck. The bat file works to open the instance of MT5 and it seemingly populates the settings tab with the correct information but then almost instantly MT5 closes and nothing happens, the strategy tester doesn't run and I have no real clue as to why, also no report file is output into the report directory when MT5 closes. Below is a screenshot of the settings tab after the bat file has opened and instantly closed MT5, when re-opening the MT5 it can be seen that the settings tab is populated as per the information in the ini file.

MT5 Settings

I have tried ensuring that I have manually downloaded the tick / historic data of the pair I am trying to test as I read somewhere that it may cause an issue, I have also made sure that the pair is in my watchlist but currently none of that is helping. I am running on a Windows 11 machine if that helps with any sort of advice as to how to debug or correct this issue. 

Thanks for any help in advance.

Chris
Platform Start - For Advanced Users - Getting Started - MetaTrader 5 Help
  • www.metatrader5.com
After installation, a group of programs of the trading platform is added to the Start menu, and the program shortcut is created on the desktop. Use...
 
Plattform starten - Für fortgeschrittene Nutzer - Die ersten Schritte - MetaTrader 5 Hilfe
  • www.metatrader5.com
Nach der Installation wird eine Programmgruppe erstellt und zum Startmenü hinzugefügt und eine Verknüpfung wird auf dem Desktop...
 
Hi Carl,

Thank you for the response and links, these offered some further useful information but unfortunately nothing that has solved my current issue. I seem to have narrowed down the problem to the fact that MetaTrader 5 is clearly seeing the ini file in the fact that it is populating the settings tab as per my above screenshot but it doesn't seem to be loading in the custom .set file into the inputs tab and then actually executing the strategy tester.

I have also tried hard coding the .set file parameters into the initial .ini file itself as was shown in one of the links you provided but this also seemed to provide the same result of the settings tab being populated but the inputs tab not.

I have also tried running the .bat file as administrator and this causes MetaTrader to open, load the settings into the settings tab but still ignore the input tab but this time MetaTrader 5 didn't almost instantly close it remained open but in a static state.
 
Kingston86:
Thanks for any help in advance.

Forum on trading, automated trading systems and testing trading strategies

Automating EA Optimization

fxsaber, 2023.08.30 09:00

Full automation of the tester and work with the results of optimization and single passes.

  1. Automation - MTTester.mqh.
  2. TesterCache.
  3. SingleTesterCache.
 
Hi Fxsaber,

Thank you for the links, I have read these posts and the scripts but as I am not a coder by nature I don’t really understand how I can implement this into my issue or what it is showing. Could you elaborate a bit on what I am to do with this information. Thank you
 
Kingston86 #:
Hi Fxsaber,

Thank you for the links, I have read these posts and the scripts but as I am not a coder by nature I don’t really understand how I can implement this into my issue or what it is showing. Could you elaborate a bit on what I am to do with this information. Thank you

  1. Create ini-tasks like in this folder: MetaTrader5\MQL5\Profiles\Tester\*.ini.
  2. Place these ini-tasks in this folder: MetaTrader5\MQL5\Files\ValidateTasks\*.ini.
  3. Run this advisor in the terminal (not in the tester!) with the following input parameters.
  4. All ini-tasks will be executed sequentially.
Validate - собранный в EX5
Validate - собранный в EX5
  • 2020.01.29
  • www.mql5.com
Описание инструмента по ссылке . Прикреплен его исполняемый EX5-файл
 
Thanks for the response, this seems to rely on another EA being loaded which in turn will then run tests from the ini. If I am reading that correctly I appreciate that as a potential workaround but I would really like to get to the root cause as to why it cannot just be launched via command line as is stated on the MT5 website. 
 
Kingston86 #:
Thanks for the response, this seems to rely on another EA being loaded which in turn will then run tests from the ini. If I am reading that correctly I appreciate that as a potential workaround but I would really like to get to the root cause as to why it cannot just be launched via command line as is stated on the MT5 website. 

I don’t care what method of working with a tester, as long as it works.

 
Kingston86:
Hey all,  

I wonder if anyone can help me. I am trying to launch MetaTrader 5 using a batch file and then loading a custom ini file that I have created using the information on the https://www.metatrader5.com/en/terminal/help/start_advanced/start#command_line page.

This is the current information inside my bat file:

I have then created the following ini file:
I have tried saving this ini file as both UTF-8 format and UTF-16 to see if this would help with MetaTrader accepting the file but so far no luck. The bat file works to open the instance of MT5 and it seemingly populates the settings tab with the correct information but then almost instantly MT5 closes and nothing happens, the strategy tester doesn't run and I have no real clue as to why, also no report file is output into the report directory when MT5 closes. Below is a screenshot of the settings tab after the bat file has opened and instantly closed MT5, when re-opening the MT5 it can be seen that the settings tab is populated as per the information in the ini file.



I have tried ensuring that I have manually downloaded the tick / historic data of the pair I am trying to test as I read somewhere that it may cause an issue, I have also made sure that the pair is in my watchlist but currently none of that is helping. I am running on a Windows 11 machine if that helps with any sort of advice as to how to debug or correct this issue. 

Thanks for any help in advance.

Chris
Your starting date is in the future of the ending date.
Reason: