Backtesting in metatrader 5

Backtesting… A lot of people think that back testing is useless, but i disagree.  When I was using betfair I created my own program suite just to be able to back test on historical date (which I of course recorded myself) and it let me find things that I wouldn’t find in another way. My first bot was a “Lay the draw” bot where you put a lay bet on draw, wait for a goal and then hedge out a profit. Sounds easy, but there was a lot of pitfalls and a lot of parameters to tune and after some testing I at least made some few dollars on it. Before the back testing i lost money on it.

Since Forex trading and betfair trading is similar in some respects I of course started to back test my Forex strategies.  I have done a lot of research of different strategies and back tested some of them. I have also tested some indicators.

Backtesting the Forex market is way easier then Betfair since there are a lot mor resources like historical data and applications to actually do the test. I have been using MetaTrader 5 for a while and even though the “Expert Advisors (EA)” are written i C++ and everything feel kind of messy, it gets the job done.  If you haven’t done any coding i would suggest you to pick up a C++ book or online tutorial and start learning the basics. It isn´t really that hard. And when you understand the basics start searching for some MetaTrader ea tutorials.  MetaTrader doesn’t use strict c++, but it´s close enough.

So what can you do in MetaTrader 5 with expert advisors?

First of, you are able to test your strategy against historical data on different timeframes and symbols. This way you can find out if there is any potential to you strategy and get a graph something like this:


So far so good. If you find out that it looks ok but want to tweak some parameters, metatrader have a genetic algorithm that allows you to find the best parameters in a certain time frame.  Use it with caution though. Sometimes you will get really weird parameters and that is a sign that the genetic algorithm over fitted your parameters., which means that it will probably only work with that symbol and that current time frame and not the future.

You will get a graph like this where each dot represents a specific set of parameters.



So what do you do when you find a really good EA with huge profit? Metatrader allows you to run the EA in realtime and trade with real money, but you should probably start with a demo account. There are differences with back testing/demo account/real account in execution speed, ticks and a lot more that can skew the result.

If the ea still is profitable after a couple of months on demo then its time to try it out for real, but start small.  Unfortunately, eToro doesn’t support metatrader but there are other brokers that do. One option if you really want to use eToro is to setup the EA to send a mail every time it finds a trade and then place the trade manually.

Leave a Reply

Your email address will not be published. Required fields are marked *