How to Backtest Forex

Let’s talk about results in our trading strategies. And if we talk about results we are going to have to talk about backtesting when we trade.

Backtesting is simply the calculation of the statistics or the behavior of our trading strategies in the past. It’s kind of like going back and seeing what would have happened. In it we can see the yield curve and statistics associated with our operations, such as the number of winning and losing operations, how much you win when you win and how much you lose when you lose, in short, it is a scanner of our trading strategy.

1. What is backtesting for?

a backtesting It is not a guarantee of anything, but it is a sign that what you are doing does or does not make sense.. You avoid wasting time with strategies that are clearly losing. It amazes me that there are people putting their money into something that they don’t even want to know with numbers if it works or not. That what you do makes sense does not make it profitable. You will only be able to know if it is if you have the results to verify it.

2. How does a backtester work?

A backtester is nothing more than the tool to check how good or bad a strategy is. There are many platforms for backtesting our trading systems, the most popular is Metatrader (I’m not saying the best, I’m saying the most popular). In this video I show you how his backtester works.

In the end, what a backtester does is that by means of the historical data of the asset in question where you want to trade and the entry and exit rules of the strategy, it computes the results in each operation, the moment of entry and exit… It is something like if you took a pen and paper and did it manually, but in a much more precise way.

In fact, I don’t recommend doing a backtest by hand since you can cheat at solitaire or simply make a mistake in the computation, something that is more complex than what happens with a computer program.

3. Why is backtesting so important?

One thing is clear, past results do not guarantee results.
futures. But if on top of the past results of the methodology of
trading that we are applying is a disaster… or worse, we don’t know if
it is or is not a disaster and we carry it out because they have told me that
Does it work or can a person who knows a lot explain it to me, you can stick it,
but well.

Trading without looking at a backtest is like driving without knowing if in
the car in which you are going to ride, the brakes and the
throttle. Operate manually or automatically make at least one check of what you’re doing or you’ll be rolling the dice.

4. How to perform backtesting in forex?

Performing a backtest in Forex is very simple. Of course, if we have our automated strategy. If this is not the case, you will have to do it by hand as I said before, roll up your sleeves and learn some programming or hire someone to automate it for you. It’s not usually very expensive.
It can be worse for you to apply it without knowing how it is going and lose money.

If you have an already automated strategy, you already have almost everything done. You simply need the data from the broker where you are going to execute it and execute it. It usually takes seconds or minutes to get all the results.

5. Winning strategies when doing backtesting

There are many criteria that you can obtain to evaluate if your trading strategy is truly profitable. These criteria are statistics from our system to evaluate it and know if it is valid or not. Let’s go with the most common statistics or ratios:

5.1. Net Balance.

The net profit of a trading system is the profit minus losses. The more net profit, the better for our trading system.

5.2. Return/Drawdown

It is the result of dividing the profitability obtained by your drawdown (It is the longest consecutive losing streak the system has suffered).

Dividing one by the other gives us a ratio that is quite interesting, since if, for example, the result of the division is 3, we can interpret this for a risk level of 1, we have a return of 3 (in this case as a percentage). .

5.3. System quality number(SQN)

The SQN measures the relationship between mathematical expectation and
standard deviation of a distribution of multiples of R generated by a trading system.
In order to continue talking about the SQN, we must therefore define that it is a multiple of R: it is the relationship between the profit obtained and the risk assumed per operation. Thus, if in a trade we obtain a profit of €500 and we have risked €250 (the loss that we would have obtained, for example, if the stop loss had been triggered), our multiple of R would be 500/250 = 2.

A priori, the idea is fine, but we need some reference to be able to assess these figures and decide if a system is good or not. For this, the following scale is proposed:

1.6 – 1.9 Below average, but can be operated
2.0 – 2.4 Average
2.5 – 2.9 Good
3.0 – 5.0 Excellent
5.1 – 6.9 Magnificent
> 7.0 Perfection

5.4. Win/Loss Ratio

It is simply based on dividing the number of winning trades divided by losing trades.
It doesn’t take into account how much you win when you win and how much you lose when you lose, so it leaves out a lot of important information.

5.5. Sharpe Ratio

This ratio is one of the best known in the financial world. To build it we will need the profitability obtained by the system and its risk. Being the risk with the standard deviation. It measures the excess return of an investment over its risk. The higher the Sharpe ratio, the better the return in relation to the risk taken on the investment.

5.6. Profit Factor

It is another widely used indicator. Its calculation is very simple: it is about dividing the total won in positive operations by the total lost in losing operations.

If the system we are using is profitable, it must obviously have a profit factor greater than 1, since the profit will be greater than the loss.

The ideal is to have a profit factor greater than 2, with 3 being something very difficult to find. Likewise, a system with a profit factor of 1.6 can already be enough to say that we have a good strategy.

5.7. profit

This last criterion is based on taking into account andl profit only the gross profit obtained by the system.

5.8. Balance Line Stability

It is a round number between 0 and 100. The higher the stability of the balance line, the better. A level equal to 100 means that the balance is a straight line (only possible if there are 0 or 1 trades) Anyway, any value above 90 is good.

5.9. R Squared

The coefficient of determination or Rtwo It is used in the context of statistical models whose main objective is the prediction of future results based on other related information.

R-valuetwo is a number between 0 and 1 and describes how well a regression line fits a data set. When the value of Rtwo is close to 1, this indicates that the regression line fits the data very well, while an R valuetwo close to 0 indicates that the regression line does not fit the data at all.

The larger the value of Rtwo, the better the capital curve of the trading system will be. an R-valuetwo very high should result in a profitable trading system with little drawdown.

5.10. stagnation

Stagnation is a prolonged period of little or no growth in a trading system’s capital curve. We will look for the stagnation to be as little as possible.

Basically at a glance you will be able to see how your curve behaves in the results graph but I have made a video about the main ratios that are important to me.

The best software for backtesting.

The best software for backtesting can be Python, Tradestation or Matlab. Even so, they are not usually easy if you are starting and not part of a programming level and that is why platforms that are usually much simpler such as Metatrader are used. Metratrader is not usually very accurate of course, but it is more than anything and it is not bad if you take the data from your broker where you are going to apply it with real money.

Advantages of backtesting in the forex market

The advantages are obvious and we have already mentioned them throughout this article. But summarizing:

  • Information about our trading strategy.
  • Possibility of optimizing the variables of your strategy.
  • Configure broker conditions such as swaps and spreads to see how they affect.
  • Avoid implementing losing game systems.
  • Psychological advantages of having information on the behavior of our system, such as confidence and eliminating doubts.

Disadvantages of backtesting in forex

The main disadvantage when doing backtesting and specifically in Forex is that it is difficult to do it with an accuracy that comes close to reality. Having a realistic backtest is essential and with few tools we can do it like this. Another disadvantage is that the data depends on each broker.

And up to here all the aspects related to the backtesting of trading strategies. As you have been able to verify, it is very worthwhile and should become essential for you from now on if it is not already. And if it already is, what is your experience here? what platform to use to do it?

Thank you for reading!

Leave a Comment