Show Full Transcript

Have you ever worried when you’re designing and backtesting your trading systems, that they’re being affected adversely by a small number of huge outlier trades, either positive or negative that might be making you backtest results unrealistic?

My name’s Adrian Reid and I’m the founder of Enlightened Stock Trading. And in this video I’m going to show you how to deal with outlier trades so that you can rely on your backtest and develop a good optimization that’s not curve fit or finely tuned to outlier trade. So what we’re going to do, I’m going to share with you the backtest of what a couple of my trading systems from the trading system collection. And demonstrate what is and what isn’t a backtest and show you exactly how to deal with it so you know what to do when you’re designing and optimizing your own trading systems. Or working with someone else’s trading systems as well.

So on the screen here, I’ve got the analysis window open and I’m going to run the first backtest with the Freight Train, which is one of my favorite systems in the trading system collection. And the Freight Train uses the Australian all ordinaries index as a index filter. So I just have to check panel lines on there. And I’m going to run the backtest on all ASX stocks.

And just for the purpose of this exercise, we’ll use the entire market. And I’m backtesting from 1st of January, 1992 the 6th of January, 2020. So let’s run the backtest and let’s see what happens. So when you run the Amibroker backtesting, you get this trade list that shows you every single trade that the backtests would have taken.

And there’s a bunch of columns here that are interesting, but right now we’re only going to focus on the things that you need to look at to identify and remove outlier trades. So one of the tempting things to do is to look at profit and filter for the trades that generate the biggest profit and try and remove those.

But the trouble with that is if you’re backtesting with a compounding equity curve where your position size grows as your account grows, the trades in the more recent trades where the equity has really grown will appear like outliers. But actually they’re not. It’s only because your account has grown from a small base at the beginning of the backtest to a huge base at the end of the backtest. So those trades get bigger and bigger.

So when we’re looking for the outliers, we want to look at the percent profit column. Percent profit is agnostic of where the trade occurs in the backtest and how much equity you had at the time. So if you click on this percent profit, you’ll see that you can sort from lowest to highest or highest to lowest. And there’s two types of outliers that you might be worrying about.

There’s positive outliers where the trades generate a huge return relative to the rest of the trades in the backtest. And you can see a couple of those here, FGX and MMD. The first one FGX, had a profit of 1,885 which is pretty amazing. And MMD had a profit of 1441%. so that’s a positive. They look like positive outlier trades and I’ll get into the distinction between what are and what aren’t outliers in a second.

And then if you filter it from lowest to highest, worst trade to best trade, you see here this trade PNV in the backtest generated a profit of -79%. Now how do we determine what trades are outliers and what trades should be included in the backtest, included in the analysis that we’re doing? Well, the easiest way to think about this is to think about the profit that that trade generates relative to this the next trade in the list when you sequence them.

So if you look at this one, 79.5% loss. The next worst trade was 56% loss. And then the next worst trade was 46% loss. And you can see here there’s a steady progression of losing trades from down the bottom here at 24%. 24% up to 25%, 28%, 30, 34, 37, 39, 40, 56 and then 79. So it’s quite a smooth curve in terms of the trades getting worse as you go to the worse and worse trade.

79% could be considered an outlier because it’s a fair jump from the next one, but it’s a negative outlier. And the thing about negative outliers is it’s really tempting to want to exclude them from your backtest so that the equity curve looks better. And after all, this is one trade out of thousands. Why would you want to include it in your backtest?

But here’s what I want you to do. Whenever you’re backtesting optimizing your trading systems, I want you to include all the negative outliers. Now why should you do that? Well, the main reason to include all the negative outliers is that it’s going to keep you conservative. It’s going to save your skin, it’s going to keep you in the trading game.

Because if you exclude the negative outliers, when you optimize and design your position sizing and risk management roles, you’re going to be more aggressive because the worst trades have been removed. And that’s going to convince you to take more risk in your backtest because that worst trade isn’t impacting the equity curve.

But if you include the worst trades in your equity curve and you include them when you optimize your position size, you’re going to keep your risk per trade lower. Because when that worst trade comes along, that’s going to convince you that you want to have a low risk per trade so that your drawdown is lower so that you can remain comfortable.

And the most important thing with system trading is to have the confidence in your system to keep following the system, no matter what happens. So when you design your position sizing risk management rules, including all the worst trades, all the negative outliers, the chances are you’re going to get a lower risk per trade as your ideal optimal position size. And that’s going to mean that if a bad trade does come along, you stay comfortable because it doesn’t affect your equity so much.

Now it’s different with positive outliers. Okay, so with positive outliers, you really do need to think about this. Now look here. On this trade list, we’ve got results of 180%, 190%, 200, 250, 300, 500, 600, 700, 878%. And then these two really monster trades. Now this is a trend following system, so believe it or not, you do actually get trades like this in your portfolio, but they are few and far between.

And there’s a real risk to optimizing your trading system with these sorts of trades included. And the risk is this. The risk is when you optimize your parameter values, your rules, with positive outliers included, because those trades are so big, they’ll have a disproportionate impact on where you select your parameter values. Because they’re such monster trades, it’s almost inevitable that your optimization will end up curve fit to those small number of monster trades. And that means that the rest of your system is not going to be as valid as if you exclude those trades.

So when you’ve got positive outliers in your backtest, before you do your optimization, you want to remove those from the backtest. Run the optimization so the optimization is based on the results from the vast majority of trade excluding those rare monster winners. Now these couple of trades here, I actually caught those in my real portfolio. And if you follow a trend following system like the Freight Train, you will eventually get big monster trades like that.

But you don’t want to design your trading system around two or three trades out of a thousand. You want to design your trading system around the several hundred trades out of a thousand. Because that way the system is going to be more robust, more stable, more likely to make money in the future. So how do we do it? How do we eliminate these trades from our backtest?

Well, the good news is in Amibroker, it’s extremely simple to do this. All you have to do is add these stocks, these tickers to a watch list that you’re then going to exclude from the backtest. So the way you do that is you right click on the… Actually let’s highlight both. We can do them both at once. Right click on that and you can add selected results to watch list. And I’ve got this watch list called stocks that generate outliers. And all of the stocks that generate these massive moves for my systems, I just add these to this watch list. And that way whenever I’m doing an optimization, I can exclude those and my chances of curve fitting my optimization will be much less.

So we’re going to add these to this watch list. Now we’re going to run the backtest again, but I’m going to click on this filter here. Go to the exclude tab, and I’m going to exclude stocks that generate outliers. And then run the backtest again. And you watch those two monster trades will have disappeared. So let’s have a look.

So yeah, so now the biggest trade is DMP at 878% return. So the two big outliers have disappeared. Now once you’ve identified and eliminated the positive outlier trade, you can go ahead and run your optimization. You can adjust all of your perimeter values and set up your system so that you’re happy with it. So it’s stable and robust.

But then once you come to run your system, then it’s time to include those stocks back in. So when you’re running your scan each day to find the trades that you’re going to take, you want to scan the whole market. You don’t want to exclude those ones who’ve generated outliers because those outlier treads were in the past. So we need to include the whole market. So we ran our scan on the whole market irrespective of whether they generate an outlier trade in our backtest or not.

So the way you include them back in is to go to the filter settings, go back to the exclude tab, hit clear, it gets rid of that. You’ve still got the whole market here and now you can use the explore function. In my systems, in the trading system collection, they all include the explore code to identify the trades that you should be taking today based on the rules of the system. So all you need to do is hit explore and it will generate the list of trades for you to take today. So that’s how you can deal with outlier trade.

So unfortunately today in this video, it doesn’t have enough time to go through the whole system design optimization process because we’ll be here for hours. But if you want to learn how to design and backtest trading systems that are stable, robust, and profitable, maximize your confidence and your profit potential, then you need to join the trader success system.

And as a next step, I’d suggest you watch my Amibroker free web class, which is how to quickly gain the knowledge to build wealth and freedom systematically in the stock market without the market wiping you out.

So click the link below and register for the web class and I’ll see you on the other side. Again, my name’s Adrian Reid, founder of Enlightened Stock Trading, and I’ll see you in the web class. Bye for now.

Register for your free training video: Systematic Trading: The Perfect Workflow For Busy Independent Traders. Click the button below to register now.

Pin It on Pinterest

Share This

Share This

Share this post with your friends!