Skip to content
Dave Mabe
Close menu

"What if some years in my backtest have lots of trades?"

By Dave Mabe

Here's a reader question from Andrew K. (name used with permission, lightly edited for clarity).


Andrew K:

I've created a pullback strategy for swing trading. My main problem is that I keep facing some years where many, many trades occur relative to other years in the backtest. If I allow all trades to get a large sample, a majority of them are during these years.

When I optimize, this leads the filters to focus more on the years with more trades.

Essentially, my strategy now performs really well during these years in comparison to a typical year, which is not what I want.

I've experimented with maxing out the number of trades to allow a little more than the typical year, but I'm not sure how I feel about that, so I wanted a second opinion.


Dave:

This is a common scenario, especially with swing trading. And yet another reason day trading is superior (and easier).

With swing trading, you're often going to need to expand your backtest window over a large period of time.

And by doing that, you're going to have to include periods of unique market action.

For example, the COVID period in 2020.

When you backtest and optimize on that period, you're optimizing for something not likely to happen again in our lifetimes. (But if COVID happens again, your trading strategy will be ready lol!)

Here's the thing:

Your strategy should be based on a signal that's relatively unusual during relatively normal market periods.

If your strategy requires a unique market situation to work, there's a good chance the unique market situation won't occur again. Maybe ever.

Here are some next steps to think about for this strategy:

  • When optimizing, focus on trades per day and how evenly distributed the trades are

  • Add more columns - this will make it easier to incorporate trades per day in your analysis

  • Try excluding one of the big trade years and optimize - some suggestions can suggest a better starting point you can use to create a strategy where the trades are better distributed

I think the entire process gets easier when you're day trading - for plenty of strategies, you can start your backtest on 2021-01-01 and avoid COVID entirely.

That's much harder with swing trading.

Nice work, Andrew - I'm looking forward to hearing how this works for your strategy.

-Dave

P.S. Amibroker users: are you trying to use ChatGPT to create a backtest only to discover how bad the LLMs are at coding Amibroker's language? You're not alone! You need my Amibroker AFL Course. It comes with a demo strategy that serves as the perfect starting point for any strategy you want to create.

Get instant access to the Amibroker AFL Course