Learn How to Deal with Outlier Trades in Your Stock or Crypto Trading Strategy Backtest

Adrian Reid (Enlightened Stock Trading) demonstrates how to identify and handle outlier trades when backtesting trading systems (example: Freight Train). He argues negative outliers should be retained to keep position-sizing conservative, while rare large positive outliers should be temporarily excluded during optimization (by adding their tickers to a watchlist and excluding them in Amibroker) and then re-included for live scans. Demonstration uses ASX stocks and Amibroker trade lists to sort by percent profit and remove outliers before running optimizations.
Questions this video answers
1 January 1990 to 6 January 2020.
Freight Train.
Australian All Ordinaries (ASX) index.
Approximately 1,885%.
Approximately 1,441%.
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 your backtest results unrealistic?
My name is Adrian Reed 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. It's not curve fit or finely tuned to outlier trades. So what we're going to do, I'm going to share with you the backtest of 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 Auditories index as an index filter. So I just had to check pattern 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 back testing from 1st of January 1990 to 6th January 2020. So let's run the backtest and let's see what happens. So when you run the backtest in amibroker, you get this trade list that shows you every single trade that the backtest 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 back testing 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 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 MND. The first one, FGX, had a profit of 1,885%, which is pretty amazing. And MND had a profit of 1,441%. So that's a positive. They look like positive outlier trades. And I'll get into the distinction between what R 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 negative 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.
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. You can see here there's like a steady progression of losing trades from down the bottom here, 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 rules, you're going to be more aggressive because the worst trades have been removed. And that's going to allow you 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 low, 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, chances are you're going to get a lower risk per trade as your ideal kind of 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. 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%, 2002-503005-00600, 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 excluded 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 trades, 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 system around two or three trades out of 1,000. You want to design your trading system around the several hundred trades out of 1000. 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 watchlist. 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 optimization won't. 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 trades, you can go ahead and run your optimization. You can adjust all of your parameter 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 generated outliers because those outlier trades were in the past. So we need to include the whole market. So we run our scan on the whole market irrespective of 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, I don't have enough time to go through the whole system design optimization process because we'd 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, then you need to join the Trader Success System. And as a next step, I'd suggest you watch my 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.
Sam.











