Categories
Forex Trading Strategies

How to Perform A True Strategy Backtest

Before you start you may wonder why a consistent trading strategy and what exactly this means. One of the biggest problems you will know when trading is that you don’t know what will happen tomorrow. We have a lot of data on what has happened so far, but every day the markets behave differently.

So you’re in need of a plan that can be adapted to a changing scenario. That’s why doing things right requires a strategy. A strategy that is able to be consistent when the market changes. Careful, I don’t mean by this that I will always win no matter what happens in the market. By consistent, I mean exploiting the inefficiency of the market for which it has been created and being successful over time (not always).

Importance of Backtest Trading

As I was saying, what you have in your hand is past data to measure how good your strategies are. We do this through what’s called a backtest, which is basically about extracting statistics from our strategies and evaluating how they’ve behaved.

The Big Backtesting Error: Over-Optimisation

The problem is when we use that data to create and measure strategies at once. This leads to over-optimization. To understand it better I will give you an example. Imagine that I tell you that if I create a winning strategy I give you a million euros but you don’t have much idea of trading. Surely you take a couple of pointers and see how they’ve worked and said the typical, “If I had come in here and gone out there…” and present me with a strategy on incredible paper. A strategy that during that time seems infallible. And that is that during that time frame surely will be.

Quite possibly if I apply this strategy I won’t get even close to the results I could expect from backtesting. Why? Basically, because I have been playing with the marked cards. I have looked for a good result without considering the strategy. I’ll explain it to you.

How to Perform a Good Backtest

Then you will surely wonder if it is possible and how we can measure the performance of our trading system without falling into this bias. The answer is to divide the time frame or the data.

Let’s go with another example to understand it better. We are doing a backtest of our strategy from 2013 to 2019. What we’re going to do is use 70% of our data to build the strategy and 30% to measure its performance. This is something like seeing what would have happened if I had actually implemented this strategy in that 30% of the time horizon. This is actually what we’re interested in, to see how it would have worked.

In Sample (IS): 70% of the data in the example above is what we call in a sample or inside the sample. I remind you that’s what we use to build our system.

Out of Sample (OOS): On the other hand 30% is what is known as out of sample or out of sample. The data we will use to measure your performance.

The Importance of Backtest

We might think that the really important thing when we observe a backtest is that the off-sample period presents favorable statistics. But on top of this, the ideal is for periods in sample and out of sample to have a similar behavior.

This tells us that the strategy behaves in both periods in the same way and shows us a clear sign of robustness. Look at our case as we can see that in both, the performance is very similar. We are facing a strategy that is a candidate to move to real.

Advanced Techniques

There are more advanced techniques to evaluate trading systems in this way, one of the best known is the walk forward test. In a few words it is how to make this division in the data but in different stretches in time. It is a question of doing this division (in sample and out of sample) in a segmented way to go a step further.

What to Do Now

My advice is yes or yes to measure the performance of your strategies with a backtest and to do it with an off-sample period. Well 20%, 30% or 40% but do it. Thus you will avoid biases and errors that make us see very beautiful profit curves that then are not real. And this means avoiding wasting money, time and frustration. This is just one more step towards objectivity.

Categories
Forex Basic Strategies

Master the Art Of Forex Backtesting With These Key Tips

Let’s talk about the results of our trading strategies. And if we talk about results we’re going to have to talk about backtesting when we trade forex. Here we go!

Backtesting is simply the bedrock of statistics or the behavior of our trading strategies in the past. It’s kind of like going back and watching what would have happened. In it we can observe the yield curve and statistics associated with our operation as can be the number of winning trades, losers, how much you win when you win, and how much you lose when you lose, in short, is a scan of our trading strategy.

What Good is Backtesting?

Backtesting is not a guarantee of anything, but it is a sign that What you’re doing is either good or no good. You avoid wasting time with strategies that are clearly losers. I’m very surprised that there are people putting their money into something that they don’t even want to know with numbers whether it works or not. That what you do makes sense doesn’t make it profitable. You can only tell if it is if you have the results to contrast it.

How Does a Backtester Work?

A backtester is nothing other than a tool to check how good or bad a strategy is. There are many platforms to backtest our trading systems, the most popular is the Metatrader (I don’t say the best, I mean the most popular).

A backtester at the end what it does is that through 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 time of entry and exit. It’s kind of like taking a pen and paper and doing it manually, but much more precisely.

In fact, I do not recommend you to do a backtest by hand since you can cheat yourself or just make mistakes in the computation, something that is more complex to happen with a computer program.

Why is Backtesting So Important?

One thing is clear, past results do not guarantee future results. But if on top of the past results of the trading methodology we are applying it is a disaster. or worse, we don’t know if it’s a disaster or not and we carry it out because I’ve been told it works or I explain it to a person who knows a lot, you can hit it, but fine.

Trading without looking at a backtest is like driving without knowing if the brakes and accelerator work well in the car you’re going to ride. Operate manually or automatically do at least one test of what you’re doing or you’ll be rolling the dice.

How to Perform Forex Backtesting?

Carrying out a backtest on Forex is very simple. Yes, if we have our automated strategy. Otherwise, you’ll have no choice but to by hand as I said before, roll up and learn some programming or hire someone to automate it. It is not usually very expensive, you can get worse to apply it without knowing how it goes and lose money.

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

Winning Strategies When Backtesting

There are many criteria you can obtain to evaluate if your trading strategy is really profitable. These criteria are statistics of our system to evaluate it and to know if it is valid or not. We go with the most common statistics or ratios:

Net Balance: The net profit of a trading system is the profit less the losses. The more net profit, the better for our trading system.

Return/Drawdown: It is the result of dividing the profitability obtained by its drawdown (it is the biggest consecutive loss streak suffered by the system).

Making the quotient of both turns us into a proportion that is quite interesting because 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 in percentage).

System quality number (SQN): The SQN measures the relationship between mathematical hope and the standard deviation of a multiple distribution of R generated by a trading system. To be able to continue talking about 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 transaction we obtain a profit of 500 € and we have risked 250 € (the loss we would have obtained for example if we had skipped the stop loss), our multiple of R would be 500/250 = 2.

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 purpose the following scale is proposed:

  • 1.6 – 1.9 Lower than normal, but can be operated
  • 2.0 – 2.4 On average
  • 2.5 – 2.9 Good
  • 3.0 – 5.0 Excellent
  • 5.1 – 6.9 Superb
  • > 7.0 Perfection

Win/Loss Ratio: It is simply based on dividing the number of winning trades among the 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.

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. Assesses the excess profit of a given investment above its risk. The higher the Sharpe ratio, the better the return on the risk taken on the investment.

Profit Factor: It’s another fairly used indicator. Their calculation is very simple: it is a matter of dividing the total earned in positive transactions by the total lost in loss transactions. 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 idea is to have a profit factor greater than 2, being 3 something very difficult to find. Similarly, a system with a profit factor of 1.6 can already be enough to say that we have a good strategy.

Profit: The latter criterion is based on taking into account the benefit only the gross benefit obtained by the system.

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.

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

The R2 value is a number between 0 and 1 and describes how well a regression line fits a data set. When the value of R2 is close to 1, this indicates that the regression line fits the data very well, while a value of R2 close to 0 indicates that the regression line we see does not resemble in any way the data. The higher the value of R2, the better the capital curve of the trading system. A very high R2 value should result in a profitable trading system with little drawdown.

Stagnation: Stagnation is a long period of time with little or no growth in the capital curve of a trading system. We will try to keep the stagnation as low as possible. Basically, at a glance, you will be able to observe in the graph of results how your curve behaves.

The Best Software for Backtesting

The best software for backtesting can be Python, Tradestation, or Matlab. However, they are not usually simple if you are starting out and not part of a programming level and that is why they use platforms that are usually much simpler such as Metatrader. MetaTrader is not usually too accurate of course, but it is more than anything and it is not wrong if you take the data from your broker where you are going to apply it with real money.

Advantages of Backtesting

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

-Information about our trading strategy.

-Possibility to optimize the variables of your strategy.

-Configure broker conditions such as swaps and spreads to see how they affect.

-Avoid deploying losing systems.

-Psychological advantages of having information about the behavior of our systems such as trust and the elimination of doubts.

Disadvantages of Forex Backtesting

The main disadvantage when doing backtesting and specifically on Forex is that it is difficult to do it with a precision that comes close to reality. Having a realistic backtest is fundamental and with few tools, we can do so. Another disadvantage is that, like everything, you need the knowledge to carry it out. And so far all aspects related to backtesting of trading strategies. As you have seen, it is very worthwhile and should become a must for you from now on if it is not yet.

Categories
Beginners Forex Education Forex Basic Strategies

The Importance Of Strategy Testing

Creating a successful, consistent and profitable trading system is the aim of any forex trader, however, it can take years of experience and practice to actually come up with one, not to mention the fact that even a strategy that was once successful, won’t always be.

If you have traded for a while, you know what making consistent winning trades means that you can’t just look at each trade completely fresh, you need to have a set of boundaries and rules that you have put in place, not only to find the best trades but to also act as protection for your account, otherwise known as risk management.

So let’s say you have come up with a new strategy, on paper, everything looks good. It takes into account pretty much everything you can think of and you can see no reason as to why it won’t work, you just jump straight into the live markets with it right? No! You need to test it, and there are a number of different ways that you can do this.

Before you do any sort of live testing you need to ensure that your strategy would survive something called a backtest. This is a way of looking at the historical data from the markets, looking at how they moved and applying your strategy to what has happened in the past, if your strategy holds up well then it shows that it offers a bit of resilience, however, if the backtesting shows times where the strategy would have blown or had a large number of losses in a row, then it may need a little tweaking to sort that out.

If the backtesting all passes, then there is one very important aspect of testing that is required, demo it. Using a strategy on a demo account lets you test it out in real-time on market conditions that are very similar to the live markets. The key to using a demo account is that there is no risk, you are able to test it out, it if brings a few losses, you can adapt it to fix whatever aspect caused the loss and then continue to test, this should be done for an extended period of time, months for proper safety and through multiple different market conditions such as trends.

When testing the strategy there are a few other aspects that need to be tested, no strategy is 100% bulletproof, so looking for the signs in the market where your strategy won’t work is just as important as getting it to work. Maybe the strategy won’t work during major economic news, maybe it only works in an up or downtrend, these are the things that testing lets you work out and then once going live will allow you to avoid such events when using your actual capital, this acts as another form of protection for your account.

The main downside to testing is that it lacks some of the things that you get on a live account, things like slippage and commissions. These can really impact your profitability especially if your strategy looks at taking lots of small profits. So keep this in mind when testing, be sure to subtract an amount form the figures given in order to account for these.

The more testing you do, the better your strategy will be. We know that it can be a little boring going over the same thing over and over again, you also want to get that strategy trading live, we understand that and always feel the same way. However, diligent testing is the only way you can be sure it will be profitable and is a vital part of creating a new strategy. If you want a strategy to be profitable, it needs to be tested thoroughly.