After you have built an EA, you need to test it before running in real account. There are two ways you can test on you EA.
First – Create a demo account and let it run in real time.
Second – Test it in the Strategy Tester
This topic will help you to discover how to tester through Strategy Tester. From my point of view, the key benefits of strategy tester are as below:
- Test the EA over a period of time
- Test the EA if the trades are executed accordingly to the critireas
- Test the Win and lost ratio of the EA
- Test the optimize point of EA that generates the best win and lost ratio (This will not cover in this tutorial)
Let’s go through the tutorial together.
Now, you need to set all the tester parameters in the strategy tester in accordingly to different test scenario. In my scenario, I am using the expert advsior that have been created in previous tutorial. To recap on previous chapter, myEA is written for 5 minutes chart to create a buy trade on previous closed bar high in when previous 5 EMA (Exponential Moving Average) is higher than previous 13 SMA (Simple Moving Average), vise versa to the sell trade condition.
For myEA, below is my test parameters.
Set the first top right category to “Expert Advisor”. There are
Find myEA.ex4 on the from the drop down list.
Set the Symbol to “USDJPY”. Find the symbol pair you want to test on. Search on the drop down list for USD JPY.
Set Model to “Every tick (the most precise method based on all available least timeframes to generate each tick) . This is the most accurate option to test on different time frame for Forex. Each of the tick on the strategy tester will be generated from the history. Note that the tick might be missing if the date is too long ago, especially the on lower timeframe such like M5 and M1.
Set Period to M5, since I am executing myEA in M5 timeframe.
Checked use date button and set the From: 2017.01.01 and To: to 2017.01.29
(NOTE: You must set the timeframe to nearer timeframe. To ensure the history tick is available, ensure the timeframe with the date range that you have selected is able to be visible on the chart. Scroll to the chart in the date range and period that you have selected)
Now you could click on the Start button. Strategy tester will take couple minutes to process the history with the EA. The processing time is depending on the date duration and period that have been selected.
When the date duration is longer, processing time will be longer, vise-versa. When smaller period, more histories need to be processed, the longer processing time it will be.
During processing, all parameter settings will be disabled, except the stop button. You could notice the blue progress bar elapsed in time. Stop button will stop the entire processing and the result will be incomplete.
Once the processing has completed, progress bar will fill up the entire section, all the parameter settings will be enabled and Start button is visible.
Now, it is the time to analyse the EA result. Click on Results tab. You will see all the trades that are been executed by the EA, whether is instance execution or buy stop/sell stop or buy limit/sell limit, with corresponding trade details – times, price, stop lost and take profit values. The trades are labeled in alphabets accordingly. In this way, you could track when the trade is activated from buy stop/sell stop or buy limit /sell limit to buy and sell trade when the value meet the stops or limits.
On graph tab, you could see the Balance in blue and Equity in green. This shows the EA performance in the long run. In this example, it didn’t do well in the middle and improving on the end of the date.
On the export tab, it shows the summaries of the EA statically. Here you will know how many trades in total, how is the wining and lost trade. With these, you can calculate win and lost ratio. You also could know the profit and lost that are been made by the EA.
Through these numbers, you could calculate the wining probability through the formula below:
Average Profitability per trade =
(Profit trade (%) x Average Profit Trade) – (Lost trade (%) x Average Loss trade)
Wining probability is vitally important for a successful EA. An EA should consider this factor aside win and lost ratio. In long run, average profitability will decide how much you earn or lost over a long period.
Last tab of strategy tester is journal. This tab is showing the messages for EA. For a EA writer, you must know how to read the messages from this tab. Error messages or warning could help you to understand if your EA is executing the trade. So, you must study message from this tab to ensure there is no error or warning is shown.
A second way to determine your EA is correctly written or the trade is executed in expected criteria, you must view with the help of chart. To do that, after compilation, at the Settings tab, click on “Open chart” button. This will launch up the Symbol with all the trades with corresponding timeframe.
Now, you will see the chart template is in default template – Black background. You SHOULDN’T load existing template, this will delete all the buy/sell histories in the chart. You SHOULD only change the chart template (i.e background color, candle stick colors) manually. Now click on “Results” tab of Strategy Tester. Double click on the particular trade, for instance #2. The chart will scrolled to the time automatically without the hassle of identifying each single trade manually. Hence, from this, you should able to analyse if the trade is executed accordingly to the criteria. Feel free to add in any indicators to help you analyse.