Trader’s Tech – Writing Your Own EA Part 36 – Strategy Tester

Forex RobotIf you’re new to this series and want to check it out from the beginning, you can find that here. And look here for a list of all the programming articles.

In Part 35 we discussed adding our two reusable functions PcntTradeSize() and MAXover() to our EA. We’ve briefly touched on using the Strategy Tester to see if your EA is doing what it’s supposed to do.  This time we’ll discuss more of the extended functions of the Strategy Tester.

MT4′s Strategy Tester is designed to help you optimize your strategies so as to make them more profitable. You’ll hear traders tell you not to over-optimize your strategy. I know, I scratched my head and said to myself “what does that even mean?” too.  Well, what they’re telling you is that tweaking your strategy to conform to a set of historical data (we call that curve fitting), just plain doesn’t work very well.  You’ve seen the disclaimers, “prior winning does not guarantee future success”. That’s very true. The market changes in subtle ways every day. You may have a “killer” strategy that makes tons of faux cash in back testing over the last ten years, but continually loses going forward. And tweaking the strategy to get the most profit by changing your TP or SL by two pips or using slightly different moving average values won’t make any difference.

Having said all that, optimization can still benefit you. But you have to look at more than just the profitability of the settings.  In the past, I have back tested and optimized EAs for more profit, but discovered that I was only getting one or two additional trades hitting profit and making my results look dramatically different. But statistically, they were only what we call outliers. For those of you unfamiliar with statistics, an outlier is a result that lies outside (hence out-lier) the normal results bell curve and a statistician would reject the result as invalid. Trading robots depend on statistics for their profitability and we can’t use statistically unsound data to predict statistical results. So, while we may look at profitability as one of our test results, we should also look at other statistics, like percentage of winners/losers, average winning/losing amounts, etc. Since I’m not a statistician, most of this is actually outside the scope of our programming discussion, but I wanted to touch on it so you don’t go crazy running tests and thinking you’ve found the holy grail (hint, there is no holy grail. But you’re a trader and you already know that. ;))

We also need to touch briefly on tick data integrity, but I’m going to leave that to a future discussion. That’s a pretty big subject. For this installment, I’m just going to show you how to use the optimization features of the Strategy Tester (ST.)

Trader's Tech - Strat Tester 5One of the reasons we use external variables, is so we can allow the ST to plug in the values for those variables when optimizing our EA. To do that, click on the Expert properties button in the upper right corner of the ST.

 

Trader's Tech - Strat Tester 6Notice your whole list of external variables are here. If you want the tester to plug different values into a variable, just check the box to the left of the variable name. Then use the Start, Step and Stop fields to designate what numbers to plug in. It will plug in the numbers starting with the Start field, ending with the Stop field and stepping with the Step field (I know, 10 points for Captain Obvious, right? – I just want to be sure we’re all on the same page.) The Value field is only used for variables that are not going to be optimized. If the checkbox is not checked, the Start, Step and Stop fields are ignored.  It’s all well and good to try optimizing everything, but remember the ST will complete a full test for every possible combination of numbers in each field. So, in this case, it will run the MA1 from 3 to 10 stepping 1 each time (8 iterations) and run the MA2 from 30 to 100 by 10 (8 iterations.) 8 X 8 is 64 executions of the test for the specified date range. That could run for a VERY long time – depending on the date range, the time frame and the speed of your computer. If we were also to test the SLPips and TPPips, we could increase the number of test iterations exponentially. It probably wouldn’t be very pretty. But, if you’ve got an extra computer lying around not doing anything, maybe you could run some pretty exhaustive tests.

Trader's Tech - Strat Tester 7The last step you have to take is to check the Optimization checkbox and click the Start button.

 

Trader's Tech - Strat Tester 7When the test executes, you can keep track of its progress with the status numbers above the thermometer bar.

 

Next time we’ll talk about interpreting the results of the strategy tests.
Thanks for your attention and please follow me on Twitter and LinkedIn.

Tim

 

here_for_you_001

1359774937_facebook 1359774984_linkedin 1359774949_twitter 1359774960_google 1359774973_rss 1360027635_youtube

Connect_With_Winners_Edge

Get trade set ups everyday!

 

 

The following two tabs change content below.

Latest posts by Tim Black (see all)

Follow our social media:
1359774937_facebook 1359774984_linkedin 1359774949_twitter 1359774960_google 1359774973_rss 1360027635_youtube

Winner’s Edge Trading, as seen on:

Winner's Edge Trading in the news

  • Dave Hanna

    Tim, I haven’t used Strategy Tester very much, but I’m trying to use it now and running into some problems. Regardless of what values I put in the date fields, or even whether I check “Use date” or not, it only generates results from about May 29th. I have set the max count of history and chart bars to their maximum values, and downloaded history in the History Center, but I still can’t get any earlier results.
    What am I doing wrong?