![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you so much Phil! You have opened my eyes. I have been looking for a fully automated solution and a command line (bash) will help me to save my time by checking trading oportunities on a weekly basis. Let me share with you guys my idea. My Mt4 is running on Wine32 and the first step is to create the file paramset.set by clicking on "Expert properties / Inputs / Save".
// now you can find the file paramset.set in path MetaTrader/tester // you can spead up Testings by unmark the option "Visual mode" // please close MetaTrader before (!!) you start the command line cd MetaTrader gedit myini.ini // you may copy/paste the Phil's data up there ; start strategy tester TestExpert=Moving Average.ex4 ... wine terminal.exe myini.ini // it will run one test on a Symbol specified in myini.ini // to test all requested Symbols would be better to run a bash. Echo makes the ini file and then starts Mt4 and so on for all symbols. gedit tester.sh // copy/paste the code below chmod u+x tester.sh // make it executable bash tester.sh // That's all. Any tests are running now and you can find all results in folder MetaTrader/tester/files On H1 it takes a few minutes;-))
#!/bin/bash declare -a symbol=("EURUSD+" "USDJPY+" "AUDUSD+" "EURJPY+" "GBPUSD+" "USDCAD+") spread=(8 12 13 18 18 19) ## you have to change name of each “Symbol()” and it's spred used in your platform. Value 0 for each Symbol means use the current spread myExpert="Moving Average.ex4" ## update your expert's name ini="myini.ini" fromDate=2021.02.22 toDate=2021.02.28 Nr=0 ## do not touch this counter ## now loop through the above array for i in "${symbol[@]}" do echo "; start strategy tester" > $ini echo "TestExpert=$myExpert" >> $ini echo "TestExpertParameters=paramset.set" >> $ini echo "TestSymbol=$i" >> $ini echo "TestPeriod=H1" >> $ini ##you may change timeframe echo "TestModel=1" >> $ini ##you may change test model 0 1 2 echo "TestSpread=${spread[$Nr]}" >> $ini echo "TestOptimization=false" >> $ini echo "TestDateEnable=true" >> $ini echo "TestFromDate=$fromDate" >> $ini echo "TestToDate=$toDate" >> $ini echo -e "TestReport=tester/files/$symbol""report" >> $ini echo "TestReplaceReport=true" >> $ini echo "TestShutdownTerminal=true" >> $ini wine terminal.exe $ini let "Nr++" echo "************ I'm just testing $i poz. $Nr of ${#symbol[@]}" mkdir -p tester/files/"$(printf %02d $Nr) $i" mv tester/files/*.* tester/files/"$(printf %02d $Nr) $i" done echo "Test of ${#symbol[@]} symbols finished."
I hope that helps somebody.
Good luck!
P.S. This article is dedicated to the memory of DJ Thomas Coastline. He has succumbed to cancer at the age of 35.
Command line arguments and custom configuration files are described in detail here:
https://www.metatrader5.com/en/terminal/help/start_advanced/start#configuration_file
At the bottom of the page you find an example config file to start a strategy test/optimization.
Thank you so much Phil! You have opened my eyes. I have been looking for a fully automated solution and a command line (bash) will help me to save my time by checking trading oportunities on a weekly basis. Let me share with you guys my idea. My Mt4 is running on Wine32 and the first step is to create the file paramset.set by clicking on "Expert properties / Inputs / Save".
I hope that helps somebody.
Good luck!
P.S. This article is dedicated to the memory of DJ Thomas Coastline. He has succumbed to cancer at the age of 35.
Thank you !! it helps a lot.
here is my adjusted code (Working on Win10) ,
Have a good day!
guys I can start MT5 from command line like "path\terminal64.exe" config: "configpath"
But this just starts mt5 it does not run strategy tester. Is there any way to directly run ST from command line?
You need to add a section to ini file with [TesterInputs], than the test should be started, mine looks like this:
[Tester]
Expert=Market\Some_EA.ex5
Symbol=XAUUSD
Period=M5
Optimization=3
Model=1
FromDate=2021.01.25
ToDate=2021.01.29
ForwardMode=0
Deposit=10000
Currency=EUR
ProfitInPips=0
Leverage=500
ExecutionMode=120
OptimizationCriterion=0
Report=M1-W3.xml
ReplaceReport=1
ShutdownTerminal=1
[TesterInputs]
fNS=true||false||0||true||N
fTrBuy=true||false||0||true||N
fTrSell=true||false||0||true||N
fHO=false||false||0||true||N
Flag_Use_hedge=true||false||0||true||N
iMO=10||10||1||100||N
But there is a bug in Metatrader 5, when Optimization is used to thest all assets in market overview than the XML report is always empty, that sucks and needs to be fixed soon :(
https://www.metatrader5.com/en/terminal/help/start_advanced/start
You need to add a section to ini file with [TesterInputs], than the test should be started, mine looks like this:
[Tester]
Expert=Market\Some_EA.ex5
Symbol=XAUUSD
Period=M5
Optimization=3
Model=1
FromDate=2021.01.25
ToDate=2021.01.29
ForwardMode=0
Deposit=10000
Currency=EUR
ProfitInPips=0
Leverage=500
ExecutionMode=120
OptimizationCriterion=0
Report=M1-W3.xml
ReplaceReport=1
ShutdownTerminal=1
[TesterInputs]
fNS=true||false||0||true||N
fTrBuy=true||false||0||true||N
fTrSell=true||false||0||true||N
fHO=false||false||0||true||N
Flag_Use_hedge=true||false||0||true||N
iMO=10||10||1||100||N
But there is a bug in Metatrader 5, when Optimization is used to thest all assets in market overview than the XML report is always empty, that sucks and needs to be fixed soon :(
https://www.metatrader5.com/en/terminal/help/start_advanced/start
This is sensational information - Thanks all for providing commentary in this thread, just what I was looking for (was hoping such a thing was possible!).
I'm not particularly accross such scripting coding and although I'm going to research further, is there syntax to run through a number of EA's, perhaps in a given directory, for a single FX pair for backtesting purposes whilst spitting out a backtesting report per EA?
Eg. I'm hoping to automate backtests of a bulk of EA's within MT5 and having a *.htm *.html file output alike what you can manually generate. As you can imagine, this is a time consuming exercise doing manually!
Thanks in advance ... its appreciated!
where do you place this binbash script? Does this work on OSX?
It is not clear to me which of this code in the thread is for MT4 or MT5, can someone help me understand how to backtest multiple ea's on specific pairs on my Mac?
Thanks