In Part 27, we identified a coding error and fixed it. We also changed the values in SLPoints and TPPoints to reflect our 5 digit broker (only if you have a 5-digit broker – look here for more information on that.) I mentioned in passing that I like to test with default numbers, if possible. The reason for that is another of MT4‘s quirks. When you change values for what MT4 calls the “Inputs” (the numbers we’ve been calling external variables) at runtime, MT4 seems to be inconsistent in using those numbers. It will use them for the current run, but it may or may not hold those numbers for subsequent runs of the strat tester. I find it to be true in running the EAs live as well. So, be sure to check the inputs every time you run the EA to be sure you have the values you want.
I increased the SLPoints and TPPoints by a factor of 10 to 150 and 250 respectively to allow for the extra digit in prices. Let’s run the ST and see what results we get now.
Yes! We got 162 trades. Remember you may not be using the same data set as I’m using, so your results may vary. My next step is to look at the journal and check back through the chart to see if the trades occurred at the proper time. The very last trade I had stopped when the tester ran out of data, so I’m going to look at the trade just before that.
My apologies, this graphic is just a tad busy. You can see the ST Journal by clicking on the Journal tab at the bottom of the ST window. The Journal contains tester entries in addition to the entries our EA generates (anywhere we’ve used Alert and Print statements for logging.) Each entry contains two date/time columns. The leftmost date/time column is the actual local time on your computer when the test was run. The rightmost date/time is the date and time of the bar in the dataset on which that event occurred. So you can track the event back to the chart using this date/time. For this particular event, I’ve tracked it back to 06/18/2013 at 08:40 for entry and 09:42 for stop loss. The red boxes on the chart surround that price action. Also notice the arrows and the dashed line connecting the entry/exit. Let’s zoom into the price action at the entry.
Determining exactly where the cross takes place using the chart is tough. In this case the cross is physically on the long black candle. But note that it’s past the center of the candle, so when this candle closed, the cross had not yet occurred. The cross occurs after the long black candle closed and before the shorter black candle closed. So the close of the shorter candle is what triggered our entry. Since the cross is downward (Green line is 30SMA, Red line is 3SMA), the entry will be short and will take placed on the first tick of the next (white) candle. The chart is a bid chart and the short entry will be at the bid, so it should be right on the open of the white candle. If this were a long trade, it would be slightly (the spread) above the open of the white candle. So it appears that the entry took place in exactly the right place and time. And that’s a good thing.
Next time we’ll talk more about the strategy tester and how we can use it to optimize our strategies. Thanks for your attention and please follow me on Twitter and LinkedIn.
Winner’s Edge Trading, as seen on: