mt4 backtesting a trading strategy
What is the MT4 Strategy Quizzer?
The MT4 Strategy Tester is a useful tools directly enclosed in Metatrader 4 to test your Good Advisor with historical information. It helps you to optimize your Ea's performance to the maximum. Ascertain how to optimize your Expert Adviser with more than 10'000 different settings in a ace run to tweet out the hidden force of your Ea.
Chapters
- Story Center
- Strategy Tester
- Backtesting
- Analysing
- Optimization
- Forward vs Backtest
Story Center
Before you tush backtest you EA, you have to download the latest history dates from your Broker. Go to Tools dangt; Options and enter in the „Max parallel bars in history" and „Max parallel bars in chart" the issue 9999999999999. Restart your terminal and press F2 on your Keyboard. Go to the currency Pair you want to download data from. Make a three-fold click on all timeframes until they are all colored alike on the picture below. Then click on „Download" dangt; OK. This volition carry a while.
Strategy Tester
Go to View dangt; Strategy Tester to opened it. Fulfil in all of the necessary information.
- Skilled Advisor: Blue-ribbon your EA you want to backtest (for this article I choose the free "Bollinger Bands EA Basic" (available here).
- Symbolization: Choose one of the Symbolization you downloaded before.
- Period: Prefer the timeframe you want to test your Expert Advisor on.
- Mock up: Choose the model you want to test your Adept Advisor on.
- All Tick of (the most precise method based on whol available least timeframes to generate to each one beat)
- Control points (a very crude method based along the nearest less timeframe, the results must not be thoughtful)
- Visible prices only (fastest method to psychoanalyze the bar simply complete, only for Ea that expressly see to it bar opening)
- Spread: Pick out a Virtual Spread for you backtesting. A reasonable value is 2 pips. (plant 20 for a 5 digits agent and 2 for a 4 digits broker)
- Use date stamp: Complete from when to when you need to make the backtest.
- Visual mode: If you prefer this option, the graph will pop-up and you potty easily and visually hear how you robot is trading. With the little bar you can adjust the speed of the computation.
- Expert properties: Here you can change the properties of your robot. In the "Examination" tab you bathroom choose how much Initial deposit and Currency you want to examination arsenic fountainhead as if you desire to trade Long danamp; Short positions or only one of them. Go to the Inputs tab to change the Value of your robots Variables.
- Symbol properties: Shows you or s useful information about the up-to-date Symbol
- Exposed chart: If your backtest is finished you can take a deal all trades on the graph.
- Modify expert: If you rich person the source code of your Expert Advisor you can commute it by clicking here.
Backtesting
If you have set all parameter listed above, you can start your backtest by clicking on the "Start" button. If the backtest is finished you find below the Result tab and 3 refreshing tabs. The Graph, News report and Journal tabs. Read the next chapter "Analysing" to check more around these tabs.
Analysing
After backtesting your Expert Advisor it's important to analyse the psychometric test results
Result tabloid
In the result tab you find the whole trades your EA has made during the test. The Order Type (buy, sell, buy stop, sell give up, buy limit, trade limit), if the Order was deleted, mortified, squinched by the EA, or reached the Study Profit (T/P) operating room the Stop Loss (S/L). You can see the Order number, his outdoors damage, Stop Deprivation and Adopt Benefit (if available), the trades profit and the current account Balance.
Graph tabloid
In the graph tab is not much to say. You can see the graph of the EA's trades. On the right is the account balance and below the amoun of trades.
Report tab
This is an important tab. Complete the detailed information are Here. I exclusive explicate those who are non self-instructive and important for me.
- Gross profit: Total profit, the sum of all profitable (overconfident) trades.
- Gross loss: Total departure, the essence of all negative trades.
- Profit factor in: Profit factor is adequate the flagrant profit sectioned by the crude loss. High is better, anything above 1.5 is advantageous.
- Expected pay up off: Is the total profit divided by the number of trades.
- Absolute drawdown: The absolute drawdown shows the divergence between the initial deposit and the smallest value of the equity.
- Maximal drawdown: The difference between one of the local anaesthetic maximums and the subsequent borderline of the fairness. The largest value is taken.
- Relative drawdown: Equity drawdown in monetary terms that was recorded at the consequence of the maximum fairness drawdown in percent.
Journal tab
The journal tab of the MT4 Strategy Tester is not important to most of you. It is only interesting for Expert Advisor developer to find some errors in the code.
Optimization
The possibility to optimize your Practiced Adviser in a single run is the most impressive about Metatrader Strategy Tester. If you use this possibility right information technology will help you a lot to detect the flawless settings for your EA. To use this choice you sustain to check the "Optimisation" box seat in the Settings tab of the MetaTrader 4 strategy tester and then attend the "Expert properties". In the "Testing" yellow journalism you can choose happening which criteria the Ea should be optimized for. Here I choose "Benefit Factor", so the Metatrader Strategy Testerdannbsp;will optimise the EA for maximum Profit Factor in. Just you can also set other criteria.
Like a sho move on to the "input" tab. Here we are interested by the "Starting line, Step and Stop" columns. For this demonstration, I testament test some different Take Profits levels in combination with some antithetical Stop Loss levels and the Inverse Strategy function. I check the box next to the Take Profit an Stop Loss Variable and set the Start = 20, Step = 15, Stop = 95 (realize the picture below) and thedannbsp;Inverse Strategy function to Get=false, Plosive consonant=true. Press OK and Start your Optimized backtest. Metatrader Strategy Testerdannbsp;will like a sho run your EA's profit several times with the compounding of all these different settings. The Take Profit and the Stop Lose have 6 setting (20, 35, 50, 65, 80 ,95) and the Inverse Scheme has 2 (false and honorable). This makes a total of 72 passes (6x6x2).
After the calculation is through with (it took me about 7 minutes) you will be able to go to two new tabs called "Optimization Results" and "Optimisation Graph". Thither are the results of all Passes. On the Optimization Result (on the ikon sorted by the most Earnings factor) you will see all 72 passes with their Profit, Summate trades, Net income component and then on. You tin can see that the pass 69 made the best Profit Factor. It made 1.36. This is not overwhelming good only we optimized only when 3 functions. Click with the right computer mouse button on the unsurpassed result and choose "Set Input Parameters". If your quizzer jams, look in the journal check for clues. It English hawthorn be because you have tried to optimize too many parameters in the one pass.
Connected the "Optimization Graphical record" you see every the pass below and the optimized parameterdannbsp;(profit factor in this example) on the right side.
If you right away go to the input parameters you see that these settings are now saved. You see that the Take Net is still 50, the Stop Loss has changed to 95 and the Inverse Strategy in zero on trustworthy. Make a normal single backtest with these settings to see all minutes or to visualize the trades in a graph window. (You can now also save the settings to access them advanced)
If you nowadays take a consider the EA you come across that his performance has increased significantly.
Forward testing vs Historical backtesting
Afterward you optimized your Expert Advisor you want to try information technology now in a forward test. Gardant exam means to test your EA in a demo surgery real account with echt commercialise conditions. Try IT first happening a demo report for quondam then you fire showtime on a tangible account. When you number one test your optimized EA in a ahead test you wish probably quickly see that you are loosing money in the forward test although the backtest where incredibly good. Let me throw you some reasons why this is so you said it you can prevent this.
Optimized Parameter
If you optimized an EA you do not only want to have the settings with the most profit but the settings with a profit and a good profit factor (the profit of all winning trades divided away the loss of all loosing trading). To make a point the scheme tester optimized the EA with a high gain factor proceed to „Proficient properties dangt; Testing dangt; Optimization" and stage set the Optimized parameter to Profit Factor.
Wrong Model
Before you optimize an EA you have to make sure what Model you have to use. If you know that you EA only trades along the porta of a Candle and you use only Flat SL an TP and no Position Management like TrailingStop, you can use the „Wide-eyed price only" or „Check points" model, which are very allegretto.dannbsp;But for everything else you rich person to choose the „Every Check" Model. Or you optimize IT first formerly with the Check points and check the result with the Every Beat model. If the results are Sir Thomas More or less equal, you can only optimize this EA with the „Control points".
Finished-optimization
The first thing is that you tend to all over-optimize your EAs. Let ME quick explain what over-optimisation (curve fitting [wikipedia]) is: You have to be intimate that with the mt4 strategy tester you can well get a really good backtest curve by backtest all stimulation parameters of an EA with a great deal of steps. But you aren't looking for a nifty backtest result. You want to be victorious in presumptuous examination so you have choose inferior steps. For instance if you lack to optimize the StopLoss 40 to 160 and the TakeProfit from 20 to 80, do not optimize every single stair. Choose a step of 10 for the StopLoss and a step of 5 for the TakeProfit. This manner the backtest will comprise less profitable but less complete-optimized. Another advantage, if you take less steps, is that the optimisation process is very much quicker. So how to hold sure your backtest is not over-optimized? You force out do this with a simplex trick. If you test 1 year vertebral column you want to split off the last third or fourth of the year and optimize only the rest. If you optimized your Ea test information technology on the piece that you just disconnected off. If you get more or less an as good performance, your are unspoilt to expire. If your EA is over-optimized you bequeath envision the curve sloping down and you have to re-optimize the Expert Advisor once more.
Backtest Time
Do not backtest your Expert Advisor too far in the past. IT is no useful if you optimize your Ea back to the Year 2000. The markets have changed a lot. You want to optimize you EA based connected the latest History (1-3 Years). But for what time catamenia should you test your EA? In my experiences, the backtest time is non essential. You deprivation to have about 200-300 trades in a backtest to make it meaningful regardless what prison term period you backtest.
Diversity in forward examination
Do not but take unitary setting for your forward testing. You can do the optimization process for multiplex Timeframes and Currency pairs. You potty easy forward test many an settings on your VPS (Practical Private Server). Take duple settings for every Currency Pair and Timeframe. You only have not to forget to set a different MagicNumber on all chart! Also role myfxbook operating room fxblue to rails your account.
Expert Advisors with small-scale Shining Path/TP
If you have an EA that places small StopLoss and TakeProfit its hard to catch it good optimized. In the Backtest you do not sustain Slippage, order open delay and changing Facing pages. So this 3 matter will have proportional more burden on EA with small StopLoss and TakeProfit. You leave scantily notice this on an Ea with StopLoss and TakeProfit above 15-20pips. The only thing you can do hither is to set a fixed Spread (about 2 pips) for your backtest and make a forward test. Not only along a demo but also an a Live account with the minimum of lot.
Spread file clerk
If forward test your Expert Advisor you want to make sure that you use a spread filter. Sometimes the dispersed of a broker can rise quickly and if you open a trade in with a spread of 10pips you already lost roughly 8pips.
Overview
And then, in general, we derriere bunch it together equivalent this:
- Use Every Tick
- Use few optimization steps
- Look for virtually 200-300 trades.
- Test the EA forward in Exhibit or Live with small lots.
- Expend a spread filter out
You make out now how to optimize an Expert Adviser in the Metatrader 4 strategy tester. If you liked this tutorial feel free to share this page. Feel footloose to leave a comment operating theater open a discussion in the assembly.
mt4 backtesting a trading strategy
Source: https://quivofx.com/school/metatrader-4-strategy-tester/
Posted by: gonsalezfachather.blogspot.com
0 Response to "mt4 backtesting a trading strategy"
Post a Comment