How I Backtest, and Why I Believe It's Important to Do It This Way

in #trading4 years ago

Introduction

In a previous post I wrote about whether mean reversion is better than trend trading, and also about my most favorite indicators. Followers of my trading log know that I'm also writing my own strategies, indicators, algos, whatever you want to call them. In this post I'd like to go into more detail why I'm doing this, and how I'm testing strategies.

Why I Develop My Own Strategies

As traders we are need to find an edge in the markets. That edge can be anything. Over the years, I've seen and heard the weirdest stuff. Some people trade patterns, some people trade levels. I'm interested in trend following systems.

The reason the edge is so important because the market's going to do what the market's going to do. A traders' edge is often small. How small? That is what we need to figure out. It's a very sciency approach to trading. The question I wanted to answer for myself is this:

What if I had a monkey, and that monkey traded for me. How successful would that monkey be? What instructions does the monkey need to trade?

And so that started a big big rabbit hole.

The Monkey and Backtesting

At the beginning of this journey is a simple question, and I am 100% certain anyone of my followers has been asking themselves this:

What if I traded the MACD crossover blindly, is it any good?

Some other strategies involve the RSI. It's commonly known that you "long in oversold", and "short in overbought". But have you actually tried this? If not, then you have some work to do! Because I've been doing this work, and I can tell you one thing: longing in oversold, and shorting in overbought is an absolutely horrible strategy. I don't think it had even a 50% success rate. Similarly trading MACD crossovers. Nonsense. Horrible. Don't do it.

And thus, the sciencing begins. As I explained in the mean reversion vs. trend trading post, one question always always comes up: if the standard strategy is so bad, how can we make it better? That's where we absolutely need to start backtesting. Because if we get broke, we can't stay in the game long enough.

How I Backtest

There are multiple backtesting websites and apps out there. I tested a bunch, but they didn't work for me. I was always just better off simply manually testing strategies. At the time this seemed to be the most time-intensive way of doing it, but in the end worked a lot better for me. I recommend you do the same thing.

The most important part in backtesting is that we need to make it as bad as possible for ourselves, because when we're actually trading, we're going to perform a lot better than our worst, but a lot worse than our best. So, that means:

  • We take the worst entries.
  • Orders are only counted filled when price goes through the virtual order we had.
  • We test the strategy under the same conditions and absolutely unemotionally.

We think in R, and/or R-multiples. This is not the post where I will explain what that is, I'm just going to assume you do. If you don't, then please search the internet first. In short, R is the risk we take on a trade, and R is also the reward we get. So it makes sense to think in R and multiples of R.

For my own backtests I always did this. I just opened a somewhat random chart. Not always BTC, but always the same timeframe, but always the same asset for one specific "kind" of strategy. So all MACD crosses were tested on LINK on the 1h, for example. I used swing points as invalidation levels. I also tested the ATR as stop loss, but that didn't work at all for the stuff I was testing. Market structure breaks worked a whole lot better, and also made a lot more sense to myself. After I had decided on a strategy, I just used the position tool on TradingView, and everytime the condition was met, I drew a trade. Then looked to the right for success or failure. After that I made a spreadsheet where I collected all losses and wins. I would recommend you also take note of successful/lost shorts and longs. This is because crypto and similar markets like stocks, have a high tendency to go up. And if you have a strategy that doesn't seem to work so well on the short side, then maybe you only want to play longs.

After I had that data, I only made a note for myself of how successful that specific strategy was, and continued onwards to the (drumroll) FORWARD TEST.

The Forward Test

In my opinion forward testing is even more important than backward testing. The forward test is a test under real conditions. And, the same rules apply here too: we test under the worst conditions possible. We take the worst entry, and go 1R on the entry.

For me personally I have multiple timeframes that I am testing, and that I'm watching. For example, I have alerts on the screener for the 12h. The 12h obviously closes at midnight every day. Normally I wake up at around 5 to 6am. The signals that I draw on the chart I take at the current closing price without any hesitation, without any other discretion. Just straight out of bed, and then straight to trading. Well, maybe not that straight, I get a cup of tea first, and then I draw a bunch of virtual trades on the chart. For my own personal testing I'm testing 1:1 risk to reward. My idea is that a strategy that has at least an edge of 50% or more on 1:1 is a winner in the long run.

My own strategy TF (short for Trend Following) had a success rate of 74% in backtesting on the hourly. In the forward tests, under the conditions I just mentioned, it had only a 60% success rate on a 1:1 risk to reward on the 12h. Now keep in mind that I took these trades under the absolute most braindead and worst conditions possible. That means the "truth" is somewhere between 60-74%. That's actually pretty good, if you think about it.

The important thing to learn here is:

  • Knowing to have a statistical advantage. Sometimes I look at the chart, and I don't think it can go higher. I also think it can't go lower. But TF says "goes lower". I know that statistically speaking TF is right. So, do I trust my gut, or do I trust the sytem? If you've done the work above, you come to a point, where you start "believing" in your own system.
  • Markets are random. We never know when the market's going to crash again. We never know the when the next pump is going to occur. So, we need to play it "safe". How much safer than knowing what to do?
  • It helps with analysis paralysis. Once you have a fixed set of rules, there's really not much to add.
  • Knowing where the edge is helps with perfectionism. Markets are not coherent, they are more or less random. Actually less random than total randomness, but still very random. That means, dreaming of never being underwater is more or less just an illusion. And personally I am very very bad at this myself.
  • Being unemotional is one of the most important things to learn here. When I started trading, and was just dumb, I had absolutely no problem buy every dip, when something just kept on dipping. You know this feeling too. Trading needs to become mechanical. "Every time I see this, I do that." It's an exercise. The more often we do it, the better we get at it. Being underwater sucks. At least I hated that feeling of being underwater, once I improved. But after that initial learning curve I learned about the statistical edge, and then being underwater wasn't feeling so bad anymore. I knew I was getting up ahead about 60% of the time, no matter how bad it gets.

Obviously the win/loss statistics go again into the spreadsheet for evaluation.

Summary

I feel a "cold" forward test is more important than a backtest, because it tests a strategy under "real" conditions. Except, of course, it costs you the effort.

Happy testing. ;-)


If you find the information in this channel helpful, please share and invite your friends: Zettt's Trading Log. Let me know if you'd like to read more of this type of content. My private account is Zettt on Twitter and Telegram. Donations in BTC: bc1q77mmp5uzehkuafkwjcrlah5260895jf0szplsz.

Sort:  

Congratulations @zettt! You received a personal badge!

Happy Hive Birthday! You are on the Hive blockchain for 4 years!

You can view your badges on your board and compare yourself to others in the Ranking

Check out the last post from @hivebuzz:

HiveBuzz hosting #HiveChat on Twitter on January 26, 2021 at 12.00 GMT
Next Hive Power Up Day is February 1st 2021