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.
Program Properties (#property) - Preprocessor - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
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!
#!/bin/bash
declare -a symbol=("UKOUSD" "USOUSD" "AUDUSD" "EURUSD" "USDJPY" "USDCHF" "USDHKD" "BARC.L" "BATS.L" "HSBA.L" "LLOY.L" "BABA.N" "TWTR.N" "MAR.OQ" "ORCL.N" "UBER.N" "AMD.OQ" "BDEV.L" "REP.MC" "DAI.DE" "AAL.OQ" "SPOT.N" "VOW.DE" "BRKB.N" "ORA.PA" "TSM.OQ" "PLTR.N" "SNOW.N" "JPN225" "BTCUSD" "LTCUSD" "ETHUSD" "RPLUSD" "GBPUSD" "BCHUSD" "CME.OQ" "FOX.OQ" "KHC.OQ" "NWS.OQ" "TXN.OQ" "DELL.N" "RACE.N" "SCHW.N" "SPGI.N" "BRBY.L" "RDSA.L" "RDSB.L" "SBRY.L" "STAN.L" "TSCO.L" "ULVR.L" "ALV.DE" "BMW.DE" "CBK.DE" "CON.DE" "DB1.DE" "DTE.DE" "DWS.DE" "NSU.DE" "PUM.DE" "SHL.DE" "ACA.PA" "AIR.PA" "BNP.PA" "CDI.PA" "GLE.PA" "RMS.PA" "RNO.PA" "SAN.PA" "XPEV.N" )
spread=(000000)
## you have to change name of each “Symbol()” and it's spred used in your platform. Value 0for each Symbol means use the current spread
myExpert="EA_TEST" ## update your expert's name
configPath="C:/Users/XXXX/AppData/Roaming/MetaQuotes/Terminal/C348917D9E28C59E863914247686464D/config/"
fromDate=2020.01.01
toDate=2021.04.28
Nr=0 ## do not touch this counter
## now loop through the above array
for i in "${symbol[@]}"
do
echo "; start strategy tester" > $i.ini
echo "TestExpert=$myExpert" >> $i.ini
echo "TestSymbol=$i" >> $i.ini
echo "TestPeriod=H1" >> $i.ini ##you may change timeframe
echo "TestModel=2" >> $i.ini ##you may change test model 012
# echo "TestSpread=${spread[$Nr]}" >> $i.ini User current spread.
echo "TestSpread=0" >> $i.ini
echo "TestOptimization=false" >> $i.ini
echo "TestDateEnable=true" >> $i.ini
echo "TestFromDate=$fromDate" >> $i.ini
echo "TestToDate=$toDate" >> $i.ini
echo -e "TestReport=$i""report" >> $i.ini
echo "TestReplaceReport=false" >> $i.ini
echo "TestShutdownTerminal=true" >> $i.ini
mv $i.ini $configPath
./terminal.exe config/$i.ini
let "Nr++"
echo "************ I'm just testing _$i $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."
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:
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 :(
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 :(
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!
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?
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 :(
Please clarify: According to the documentation, there is the setting "ExpertParameters" that takes a *.set file. Which takes prescedent and which way works? a. ExpertParameters=<ea_name.set> <-- If this DOESN'T work, what is it's intended use? or b. [TesterInputs] as mentioned above?
Next here's the listing for "my_test_config.ini". I've tried both with the section [TesterInputs] and without. No change.
[Common]
Login=123456789
Server=MyBroker
; ProxyEnable=0
; ProxyType=0
; ProxyAddress=192.168.0.1:3128
; ProxyLogin=10
; ProxyPassword=10
; KeepPrivate=1
; NewsEnable=0
; CertInstall=1
;+------------------------------------------------------------------------------+
;| Start Expert Advisor testing or optimization |
;+------------------------------------------------------------------------------+
[Tester]
;--- The Expert Advisor is located in platform_data_directory\MQL5\Experts\Examples\MACD\
Expert=Experts\my_EA
;--- The Expert Advisor parameters are available in platform_installatoin_directory\MQL5\Profiles\Tester\
ExpertParameters=my_EA.set
;--- The symbol for testing/optimization
Symbol=GER40
;--- The timeframe for testing/optimization
Period=M15
;--- Emulated account number
Login=123456789
;--- Initial deposit
Deposit=100000
;--- Leverage for testing
Leverage=1:100
;--- The "All Ticks" mode
Model=4
;--- Execution of trade orders with a random delay
ExecutionMode=100
;--- Genetic optimization
Optimization=0
;--- Optimization criterion - Maximum balance value
OptimizationCriterion=0
;--- Dates of beginning and end of the testing range
FromDate=2025.01.01
ToDate=2025.01.10
;--- Custom mode of forward testing
ForwardMode=0
;--- Start date of forward testing
ForwardDate=2011.03.01
;--- A file with a report will be saved to the folder platform_installation_directory
Report=Reports\test_report.xml
;--- If the specified report already exists, it will be overwritten
ReplaceReport=1
;--- Set automatic platform shutdown upon completion of testing/optimization
ShutdownTerminal=1
[TesterInputs]
; -- Trading Days --
Sunday=false||false||0||true||N
Monday=true||false||0||true||N
Tuesday=true||false||0||true||N
Wednesday=true||false||0||true||N
Thursday=false||false||0||true||N
Friday=false||false||0||true||N
Saturday=false||false||0||true||N
; bunch of other inputs removed for brevity
Now, it's my understanding that the section [TesterInputs] is from MT4. The documentation for MT5 don't indicate the use of such a section. Further, it's my understanding that the [TesterInputs] section has been replaced with the key "ExpertParameters", which takes a .set file for the EA in question.
Now what? To those who have been able to get this working on MT5: - what platform are you using? - what is the command line syntax and format that worked? - what formatting and sections did you use in your custom config .ini that worked?
I have this program that I'm able to launch via command prompt in Windows or via a crafted .lnk when adding the specified arguments like this: By reading the documentation it seems that Wine interprets the arguments in the same way Windows does, and even when I'm certain that it is true for arguments presented in this way: It is not working for...
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!
#!/bin/bash declare -a symbol=("UKOUSD" "USOUSD" "AUDUSD" "EURUSD" "USDJPY" "USDCHF" "USDHKD" "BARC.L" "BATS.L" "HSBA.L" "LLOY.L" "BABA.N" "TWTR.N" "MAR.OQ" "ORCL.N" "UBER.N" "AMD.OQ" "BDEV.L" "REP.MC" "DAI.DE" "AAL.OQ" "SPOT.N" "VOW.DE" "BRKB.N" "ORA.PA" "TSM.OQ" "PLTR.N" "SNOW.N" "JPN225" "BTCUSD" "LTCUSD" "ETHUSD" "RPLUSD" "GBPUSD" "BCHUSD" "CME.OQ" "FOX.OQ" "KHC.OQ" "NWS.OQ" "TXN.OQ" "DELL.N" "RACE.N" "SCHW.N" "SPGI.N" "BRBY.L" "RDSA.L" "RDSB.L" "SBRY.L" "STAN.L" "TSCO.L" "ULVR.L" "ALV.DE" "BMW.DE" "CBK.DE" "CON.DE" "DB1.DE" "DTE.DE" "DWS.DE" "NSU.DE" "PUM.DE" "SHL.DE" "ACA.PA" "AIR.PA" "BNP.PA" "CDI.PA" "GLE.PA" "RMS.PA" "RNO.PA" "SAN.PA" "XPEV.N" ) spread=(0 0 0 0 0 0) ## 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="EA_TEST" ## update your expert's name configPath="C:/Users/XXXX/AppData/Roaming/MetaQuotes/Terminal/C348917D9E28C59E863914247686464D/config/" fromDate=2020.01.01 toDate=2021.04.28 Nr=0 ## do not touch this counter ## now loop through the above array for i in "${symbol[@]}" do echo "; start strategy tester" > $i.ini echo "TestExpert=$myExpert" >> $i.ini echo "TestSymbol=$i" >> $i.ini echo "TestPeriod=H1" >> $i.ini ##you may change timeframe echo "TestModel=2" >> $i.ini ##you may change test model 0 1 2 # echo "TestSpread=${spread[$Nr]}" >> $i.ini User current spread. echo "TestSpread=0" >> $i.ini echo "TestOptimization=false" >> $i.ini echo "TestDateEnable=true" >> $i.ini echo "TestFromDate=$fromDate" >> $i.ini echo "TestToDate=$toDate" >> $i.ini echo -e "TestReport=$i""report" >> $i.ini echo "TestReplaceReport=false" >> $i.ini echo "TestShutdownTerminal=true" >> $i.ini mv $i.ini $configPath ./terminal.exe config/$i.ini let "Nr++" echo "************ I'm just testing _$i $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."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
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
Which takes prescedent and which way works?
a. ExpertParameters=<ea_name.set> <-- If this DOESN'T work, what is it's intended use?
or
b. [TesterInputs] as mentioned above?
Thanks for the help
Let's try to clear up the confusion about what's working and what's not.
I'm running MT5 version 5 build 5430 on Mac under Wine Stable 10.00.
Trying to run the Strategy Tester from the command line, here's what I've found that DOES NOT work:
Also tried the various WIne-specific methods listed here: https://superuser.com/questions/1058985/launch-program-with-wine-using-exe-arguments
All attempts will launch the terminal successfully, but will NOT start the Strategy Tester.
Next here's the listing for "my_test_config.ini". I've tried both with the section [TesterInputs] and without. No change.
Now, it's my understanding that the section [TesterInputs] is from MT4. The documentation for MT5 don't indicate the use of such a section.
Further, it's my understanding that the [TesterInputs] section has been replaced with the key "ExpertParameters", which takes a .set file for the EA in question.
Now what? To those who have been able to get this working on MT5:
- what platform are you using?
- what is the command line syntax and format that worked?
- what formatting and sections did you use in your custom config .ini that worked?
Thanks very much for your help.