How To Use The MT5 Strategy Tester For Backtesting (EA Testing Explained)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey this is renee welcome to another video on this channel and in this video we will talk about the strategy tester in the metatrader 5. so in this video we will look at all the functions in the strategy tester i will show you the most important functions that i use to test my strategies and yeah so you can copy it for yourself and test your automated trading programs so um if you do not know what automated trading programs are and they are called expert advisors in the meter trader 5 and they are simply a bunch of code which will automatically execute trades for you if you never saw an expert advisor check out the other videos on this channel where i provide tutorials how to write a fully working expert advisor and if you have one of these programs yeah as i said you can write them on your own or you can find them in online forums then you can take these files and use them in the strategy tester to simulate trading actions in the past like you see here in the background this was simulated by the strategy tester and you will find the strategy tester in the 5 if you click on view and strategy tester or if you press control and arrow so let me just open the strategy tester and the strategy tester looks like this and before we start talking about the strategy tester you would do me a great favor if you could subscribe to this channel and like this video if you like content on trading and automated trading especially because it doesn't harm you it means a lot to me and it helps me to yeah always helps youtube to show this content to more and more people so more traders can learn about the benefits of automated trading but back to the strategy tester so when you open the strategy tester you see this window here pretty much where you have several options and you can choose one of these options there are several other tabs in this strategy tester window which we will look at later on first of all we have to choose a mode pretty much so this is really easy you just decide what you want to test if it is an indicator you click on indicator of course then you can choose any of the indicators but most of the time time you do not want to test an indicator because it simply shows signals on the chart but you want to show a expert advisor and i think every other option here is related to expert advisor back test so you can do for example a single back test or a visualized back test with which is pretty much the same there's just one difference the difference the visualized test of course visualizes the results so you can see the expert advisor trading and you can see the chart moving we will have a look at this in a second and as you maybe already saw whenever i click this we pretty much just move here to the next tab which is the settings tab and this does not only work for um single and visualize it also works for stress and delays it works for complete optimization and all the other settings so whenever you click something you simply move to the next tab and this settings tab is always the same the only difference is when i click something here the predefined settings change so as you see now if i click on visualize the optimization is disabled but if i choose any of these three modes here which include a optimization you will see that a optimization is pre-selected so that's that's pretty much the only difference um if you click one of these symbols here so i mean it would be totally okay to always click on visualize and then just do your settings here so this is um yeah just what is behind these uh these options here so let's move to settings and there where at the at the top you first of all select a program that you want to test of course so the computer knows um yeah what expert advisor he has to apply um or what expert advisor he has to simulate in the tester so we can choose for example the range breakout system i already showed the system on this channel i explained how it works you will find a video on that um if you just check the channel videos and um yeah if you are interested in this strategy and want to um for example trade it on your own i just want to see how the code works you can check out the first link in the description which is a link to a full metatrader 5 course which i created where we also write this range breakout ea but let's move on and then you guys have two buttons here first of all you can click on ide which will directly lead you to the source code of the currently selected program then you have um this button here where you can where you can pretty much load and save settings for the test we will not do this now but if you want to trade frequently or if you just want to save your settings so you you you never lose track of your testing progress then you can just use this little button here then of course you use or you select a symbol that you want to test this program on into time frame yeah then there you have another button this will show the specification for this currently selected symbol for example you see the us dollar versus japanese yen usd japanese yen is currently selected and you see all the properties pretty much of this symbol yeah in most cases this is not really important for us because the expert advisor should handle the relevant specifications on its own pretty much then you choose a period that you want to test here you can choose any period but of course you cannot fill in any any year for example where you do not have data the data in the metatrader 5 comes from the broker that is yeah the broker that is that provides your account so this will be your data feed for the strategy tester and you pretty much have to work with the data that comes from your broker you can change the broker or the server and this will have an impact on your data i think but in most cases um yeah you are pretty much bound to the um to the data that is currently inside of your metatrader5 and i think there is no really good workaround to um fill in new data but if you know another way let me know in the comments yeah for the forward um setting here i mean uh i i seriously don't really know what it does i looked it up i tried to find a definition for this i think it i mean i tested it and it divides your test into two parts pretty much um but i'm not quite sure what this does if i uh divide it into two then it simply takes the first half of this period and the second half and makes two tests but yeah i'm not quite sure what this what this does um yeah you will get two results and everything but i'm not sure if there's a difference to simply cutting the date or the period um in in two parts by yourself so let's just move on to the delay um window here this is to um [Music] uh to to simulate a delay i don't know if it's working good in the strategy tester i can just put it on i um try to test it with a delay i didn't really get slippage in the test but you can check it out on your system um it yeah as it says it should simulate slippage and recruits during your execution which is always a good thing if it is working because this will move the test um closer to the real time or to the real world to a real-world situation then you have the modeling and this is quite important because there are several modeling options here and there is for example the option to choose only the open prices and this will be a really really fast test because the tester only loads the open prices of your bars but this means if you have a system which for example creates signals in a bar so in between of the open time and the closing time of a bar this will not um work if you only use open prices because then the execution will be false and you do not get uh get good results and um there's there are other options like for example every tick and everything based on real ticks um and i would always recommend choosing one of these options because these are the most realistic options even though it is still kind of a simulation um if you use every tick or every tick on real ticks and it is not like perfect because i think um the ticks or is not every tick coming from the broker is um saved on your in your pc and you can only um test with the data which is saved on your pc so um yeah then you can choose if you want to calculate the profits and yeah in money pretty much or in pips um yeah it just does what it says so you can either choose if you want to assimilate in money um or in pips and then you can provide the leverage for this test um of course you can provide whatever level that you want to want to choose it would always make sense to choose a realistic level reg for example the leverage that that you currently use for your account and as i said you can also choose optimization methods i will explain this in a second but first of all let's go to the next tab which is the inputs tab and the inputs tab is just yeah what what the name says all the inputs for this expert advisor so it's pretty much the same as when you activate the ea on a chart then you also see the inputs and this is the same what is displayed in the inputs window it looks different because you have several columns here but it is these columns are only necessary for the um for the optimization and we will have a look at this later but first of all if you just do a single test um the check boxes here and the columns start step stop and steps are not relevant so let's go back to back test and this is the result and we have to start our test now and we we do not need these tabs they will be filled with data as soon as our test is finished so if you made all the settings that you want and the inputs that you want and you can of course change these inputs yeah so you can choose whatever you inputs you want to choose for your expert advisor test so for example this expert advisor works with times and in the range between two times and i could also adjust this and the test would then apply these inputs for this specific test so if i just click on start in the lower right corner the test will then load and you can also look in the journal and yeah see what um what the what the tester is doing right now for example i am downloading data i think this is because i choose the every tick based on real ticks um so yeah let us see what um what what the tester does so he seems to download data from the server and we will then have a look at the test as soon as the data is downloaded okay so the download is finally finished and um i think this was a lot of data that was just downloaded took some space on my on my hard drive here but um yeah you can see as soon as the um as the test starts you will then see all the ticks or all the bars simulated in the time period that you define so we um oh and what is also important the tester if you visual use the visualization opens another window so this is the visualization window and you can see um we put the settings or we try to test from the first january of 2020 and this is just the day where we start testing or the day after awards because i think it was a sunday but you can see the tesla is now simulating the strategy and you can see there is a range drawn in the chart and yeah this is really just like live trading so the the simulation is it really makes fun to watch it it it is really cool and you can use this little scroll bar here and adjust the speed of the tester so if i go to the left side the speed will be slower if i go to the right side it will be faster and if i go to the very right side the speed is insane i mean there's no uh no step in between this is kind of weird but if you go to the very right side the speed is super super fast but you can see now uh this is really like like live trading so you have the trade tab here you can see all the open orders and positions you have the history where the um the closed um deals and orders and positions are documented documented and you have all the operations like for example if there was a modification of a stop loss and everything you see everything documented in these tabs here in the toolbox of this visualization window and you can also see all the text messages coming from from your program so if you write a program you should also add some print statements so you can always keep track of what this program is doing and you can read about this in the journal so this is a great great way and what is also important as you can see here is a um there is a uh um a super trend i mean there is any indicator attached to the chart and i think this is because there is a template for this because um if you have a template oh no there is no template okay so i don't know why it is loading this um this indicator and what it is but if you want to have a template which is applied for your test you can go ahead and create a template let me show it to you real quick so i go to the navigator here and i for example apply a indicator like the moving average indicator to the chart let me do this real quick moving average applied to the chart for example 200 periods and i click on ok it is applied to the chart and we can then go ahead and say i want to save this template with the name tester.tpl and if i save this and if i run the run the test again you should see that there is a moving average attached to the chart so it automatically loads the template which is named tester.tpl and this might come in handy if you are testing a expert advisor which uses several indicators yeah this is a way how to attach a template so okay so i can speed it up just um as fast as i want and i can see all the trading and um yeah as i said all the other operations are documented in this window here we still have the original metatrader window where we also see the progress of the test and the estimated time it takes to finish this test then we have a graph which is or which will move further as the test um yeah goes on pretty much so we can oh we can just speed it up and have a look at the graph so you can see it moving yeah like here so as the test goes on you can see the equity and the the balance changing then we also have the um okay the optimization results should not be there on your pc because this is from a previous test that i did and okay you can just see the um the performance is is shown in this graph and yeah i can also watch the trades being traded in this visualization window but i can minimize it and let's just wait some more time until the test is finished then we will have another tab here which shows the testing results and where we can see several key figures which can yeah help us to evaluate this system and this test so some more seconds and you see as soon as the test is finished you can see that there is no more changing in these in the balance or equity of course and you can see the back test tab appeared um yeah this shows uh now history quality of 99 because i use this every tick based on real text setting here but still it is still a simulation at some point and this is so important and many people do not understand this there even if you have a really really good test the reside in the in the live training account can be worse or better because you will still have slippage and things like this which cannot be simulated uh like 100 perfectly in the test this is always important to remember but what we see now here is we see a lot of key figures um so a lot of information on the profit factor the the drawdown and uh the the for example the total trades the short trades the buy trades how many of these did we win and yeah i think i don't have to explain every number you can just look at it and um evaluate it on on your own and um yeah this is really really helpful i think to have a overview over a strategy so you can already say is this strategy or might it be a good strategy or is it completely uh completely rubbish and can uh can uh can it um yeah move on to the next strategy already if you scroll down a little bit in this backtest window here you can see there's also a [Music] feedback on the for example the trading days and the profits on several trading days and the times and in this case this strategy always closes um the trades on the end of the day at 20 o'clock this is this is why we only see a profits at uh 20 o'clock here and yeah but this this will be different of course for for the test um test that you made and for example we see that on wednesday and thursday we do not really make relevant profit so we could say for example we we run a new test and where we do not trade on wednesday and thursday but um there's always uh the [Music] the danger of um yeah overfitting your your settings pretty much so you do not you should not optimize it too much because this is the past of course and it cannot um predict the future so it might be an indication for future movements but this of course cannot predict the future this is also important to remember and yeah we see profits in loth by months and yeah for example here in march i think this was a period where the uh covet bureaus really took off and affected the economy and this was a great time for this strategy so there were huge profits in march um 2020 this is why we have extremely high profit there and as you see there are like um macro economic events like the covet virus which affects strategies and it is not a good idea to say january february and march worked great so i only test this i only run this strategy in three months of the year because in 2021 and 2022 there will not be a new covet i hope or at least it will have a different impact or it will come in a different month so you should always check if these results are the way they are because the strategy really performs better at the at the beginning of the year or if there was a macroeconomic event which may have caused this and this is um that's important so um yeah you you also see um like um uh the um some some other information here which you can then um evaluate and here for example you see the the closing time of your positions and this is of course als always you always have to look at this and you have to evaluate it with um with with a strategy in your mind so this will be different of course for every strategy as i said this strategy as i um [Music] as i chose the inputs here it will always close the trades at 20 o'clock and this is why of course we have a lot of trades um that will be closed at the end of the day like um oh okay this is the position holding time i mean of course the position holding time is always around a little bit more than 17 hours because we start trading as you can see in the inputs here at 3 30 and we close at 20 o'clock so this is around 16 hours so this is not really surprising that we have these results but for for another system for example these results might be really impactful and might help you to optimize the strategy okay so this is how you can use the test and um let's go back to the settings and we will have one more look at the optimization for example i can i can just choose one of these to show you how it works and for example we can optimize the profit factor you can choose what what [Music] number pretty much you want to optimize like the balance the profit factor or whatever and then you can simply run the test again and let me close at the last test if i run it again you re then see that this optimization here it does not open a um a visualization window because optimizations are yeah most of the time done in the background and we will just have to wait until we see the result and yeah and there is one more thing that i want to tell you so this was the graph from the last test and many people say um you cannot take a test and just say this will be the same result in live trading and because it there will be a huge difference and a partly agree to this statement because of course a test is only a simulation it cannot predict the future and it cannot be seen as as a as a fact like for live trading but what my studies have shown is that the results from a test can be like really similar to the results from a live trading account for example i have a live trading account and i can show you that this is indeed an existing live trading account if i go to my server here you can see this is a live trading account where i uh trade this range breakout strategy and i make um and i of course have a trading journal for this which is here where i um take all the trades that were done in live trading on a live training account and where i um yeah just look at the at the um where i evaluated and if you look at this graph this is from the first january of 2020 until um yeah until pretty much this is the same period as you can see here here as i chose here for this test and if you just compare these two graphs here you can see they are really really similar and this is now this is now um no tests here so this was live trading these are the profits that i made in a live trading account and you can see these profits for the tested period and for the live trading period on a real money account they are really really similar so even though a test cannot predict the future and it is not a like a perfect um visualization of live trading it can be really similar depending on your trading strategy i mean the differences will be higher if you are greater if you trade a one minute skyping strategy because then there is a lot more impact of for example slippage and stuff like that okay so let's go back to the optimization the optimization results are here and we only get this tab here with results and here you can see there are two results and this is because i chose this optimization method and in the inputs you can then enable the parameters that you want to optimize by clicking on this checkbox here and i only check the end of day setting because i do not want to test so many so many tests but i could activate even more here for example i could also optimize two parameters and then you see that these columns here will be relevant because you always choose a starting input a step and a stop and this optimization will then choose every single option here so it will start with a input of one for this specific setting then it will go to 1.1 1.2 1.3 1.4 1.5 until 10.00 and this shows you that there are 91 steps and this is a lot of uh there's a lot of steps and you you also have this second parameter so if i would run a test like this it would already do 182 testings because it would combine every single possibility every single option so yeah you should choose your optimization parameters wisely because otherwise it will take ages to finish but yeah you will just get a um a nice overview over the settings that might work really good and you can see for example in this case it says that for this parameter the un which means on in german period setting would be better than the house or off setting so i can go ahead and make another single back test just using this un setting for the end of day [Music] input here and you can do this for every input except for inputs like these because these are text inputs and you can of course you can't optimize text inputs because the computer doesn't know what comes after apple for example you cannot you cannot optimize from apple to to bearers for example because this doesn't make sense so you cannot optimize texts but you can optimize numbers or for example boolean inputs where you have on or off or you can even optimize enumeration inputs so yeah i think this is it pretty much about testing in the metatrader 5. i hope that this was not too confusing um i mean i jumped a little bit from the normal text to backtest to to optimization and stuff like that but just yeah just open the test and try it for yourself it is once you get into the working um into working with a tester it is like really easy to understand and you will learn everything by yourself pretty much most of the the things are kind of good explained here in this mask already if you have more questions and there's also more information of course in online forums you can always um google your questions there so as a conclusion the tester is a great tool and you should definitely use the tester if you are working with automated training programs as i as i demonstrated i think is that the tesla is a great way to to just see if a strategy could work in the future and as my personal studies have shown the testing results can be like super similar similar to the like real world um [Music] results so if you compare this this is like it is nearly the same so the testing can be a really good indication for um for the for the trading but of course there might be systems like short-term trading systems that rely on um on a steady course and that suffer from slippage a lot then the the differences might be um like really big so always yeah do not only take the result from the tester but also think about it and think um about like for example what i said here think about um events like the covet event that can affect your back test and you should always also always collect all the information and yeah like combine them if you backtest and then make a conclusion and yeah in this conclusion you should and then get to the result where you have a expert advisor a market and the inputs that you will use for your future live training and this is like the process that i use that i do for my um for my trading and it is working fine for me i hope i could help you a little bit and um yeah i would be glad as i said if you just subscribe to this channel tell your friends about it so more people can learn about automated trading and um if you already subscribed then we will see each other in the next video where we will talk a little bit more about automated trading or maybe we will write another automated trading strategy so see you then have a great time have good trades bye
Info
Channel: René Balke
Views: 1,018
Rating: undefined out of 5
Keywords: Trading, Programming, expert advisor, EA, automated trading, mt4, metatrader 4, mt5, metatrader 5, forex robot, robo trading, algotrading, forex, cfd
Id: lXn4QqNnoRQ
Channel Id: undefined
Length: 31min 48sec (1908 seconds)
Published: Fri Nov 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.