Backtesting a strategy (continuation)
In my last article i don't have the space to write all i want about. To make the things easier i provide again in this article the corresponding image, but to see all 6 first items description you need to go to read my last article.
Image 1: Historical Tester and the options on it. Explanation below (for the first ones read my last article).
- Red 7: Custom Tester Settings - In this window we have two areas. The first one is related with visual mode settings (if checked on blue rectangle). Here if we check the options, we have a chart representation added to the main chart of the evolution of "Equity", "Balance" and "Profit/Loss" with the evolution along the test. If you want to have more space available for the main chart ou if you want to add indicators to this main chart you can uncheck them and get the values on the final report where we get the results of the test. On the template dropbox we can select the template for chart presentation. On period dropbox we select the period bars we want to use to visualise the main chart. In the second one we can decide if we want to save the test originated messages and reports saved and where to save them. Also we can decide if we want at the end of the test to visualise the resulting html report.
- Green 8: Progress bar - When we are running our test this bar show us the progress time of the test till the end and also show us the time in process and the balance value of the testing account.
- Green 9: Speed selector - Here we can define the speed that the test will run between 1X (real time) till 8X and the most right one at maximum processing speed available on our system.
- Green 10: Messages area - If our strategy does some console or log output we see them on this area.
- Small red rectangle on bottom right - Here we can start our test, pause, restart where we paused, run tick by tick and stop it. If our strategy have some "@configurable" variables before the start of the test we get a window where we can define this variables.
- Blue rectangle: On this rectangle we have three checkboxes where we can enable visual mode, enable optimization (this option deserves a better explanation i will do bellow on a correspondig section) and enable message visualization. With "Show messages" checked we get some output or logs at "Green 10". With "Visual mode" checked we get the corresponding main chart we get used to on normal operation builded along the test. If we want, we can add indicators to this chart. Take in consideration that the use of this option slowdown the test as it takes more process power. If you just want to see if the strategy is profitable, run first without this option checked, change parameters if any, run again, and if you get the results you expect, you can "fine tune" your strategy running it with "visual mode" checked. This way you can spend less time.
Image 2: Historical Tester running with Visual Mode checked. If we want we can add indicators to the chart.
The "Optimization" option
When we run a "Historical Test" (know also as backtesting), sometimes we need to adjust some of the parameters of the strategy trying to achieve better results. For this we have two options: do the test, see the results, change parameters, run again and so on. It's a very high time consuming process and we must do tedious tasks at every run. There exist a better way: this is called "Optimization" in JForex. If we have this option checked when we run out test we get a parameter window like the one below (with this option checked we can't use "Visual Mode" and "Show messages").
Image 3: Running a strategy with option "Optimization" checked. In this image we have two parametrization window with diferent value to show us we must have care with this as the number of combinations can grow exponentialy. More details below.
In previous image we have two examples of parametrization. In this window at the top we have me maximum drowdown allowed on strategy run. If this value is reached the strategy stops. After this we get all the "@Configurable" variables with the default values. We can check the variable where we want to run the strategy with different values. The step box alow us to configure the hops on value until the value at left is reached. At the bottom left of the window we get the number of combinations that our choices will generate. In the window at top left, for example we want to begin with 20 pips on take profit and go up two by two pips until we reach the value of 50 pips at the left. For this the strategy must run 16 times (the number of combinations). On the second window we add other variable, the stop loss, and we want the strategy goes from 15 pips to 30 pips pip by pip. This give us also 16 combination by itself. The resulting value is the multiplication of the number of combinations of each variable what gives us 256 combinations. We can see by this example we must take care of the number of combinations because it grows exponentialy. With a big mumber of combinations and big time interval and if we don't have a fast system that can take too much time to reach the end, but is better than running each parameter individualy if we pretend to run it anyway. Below a simple example of the resulting data of strategy run with optimization.
Image 4: The results of "Optimization" run on strategy with the parameters used on the window at the center.
In the image above, we run the strategy with starting take profit with 10 pips to 50 pips going up 10 pips at time what gives us four combinations. At the bottom, the result of the strategy for each combination. The values of the columns are self explanatory, i think i don't need to explain them. As we see, Optimization can be very useful if we want to test a strategy with different values in one step. One thing i think that needs to be developed is the generation of final reports that lacks at this moment.
Note: Seems at the moment, "Optimization" does not work with a strategy with user defined enums on @Configurable variables, at least with me. But by what i find on forum, Dukascopy Support is working on that.
Ooch! Finally i ended this article where i end needing two articles to write everyting i want to say about this theme.
I hope you like this article and all the others. As usual, comment or say anything you want about this article series. Also you can follow the correspondent thread on the forum.
Trade well and prospers in your way!