Building Your Trading System – Part 3
This is Scott, filling in for Mole this week, and I’d like to continue with our work on System Building and optimization. Today we move away from the intangibles and get deep into the weeds of classifying and measuring market type and looking at how to find a prospective edge, choose an initial stop and an entry technique, and do some preliminary backtesting to work out if we have something real or are we curve fitting.
In my experience when I hear a trader identify as ” I’m a discretionary trader” this is really subconscious code for “I want to do what I want when I want and I don’t want to have any restrictions on what I can and can’t do!” Implicit in that you can almost hear the 5 year old inside your subconscious screaming “na na na na na you can’t make me trade with your stupid rules! I’ll do what I want!!”.In almost every case of the so called “discretionary trader” ongoing performance monitoring, emotional state monitoring and mistake monitoring are absent, save a quick glance at P&L. The benefits of trading within either a strict set of rules or a loose set of guidelines are huge.
The first principle that really needs to be set in stone is that
It is madness to build a trading system and expect it to work all the time – You must build a system with a certain market type in mind
Markets change character on multiple timeframes. There are NO setups, indicators or entry techniques that work perfectly at all times, and you should not believe anyone who says any different. In 2009 I first noticed that Ivan’s setups (see the cheat sheet above) would regularly give me periods with 8 or 9 winners in a row, and then give me periods of 8 or 9 losers in a row. I was intrigued about this, and wondered if I could improve my systems by standing aside from the losing times. Ivan is well aware of this property inherent to markets, which he calls easytime/hardtime. For those who trade Ivan’s patterns, because they mostly have very tight stops at the highs or lows of previous bars, when markets get choppy you get a lot of stopped out trades. When markets become smooth and orderly with few overlapping bars Ivan’s patterns perform with a huge edge. The same thing is inherent in momentum based indicators, which are a significant edge in sideways markets which are not high volatility, but which are a negative edge in strongly trending markets. Overall if you measure the edge of something like MACD or Stochastics you will find a negative edge, but if you are particular about the type of market phase you apply it to you these indicators can still be useful.
Some points, in no particular order about volatility and markets are below. If you read these closely you can see that the natural flow of markets from quiet to volatile and back again is something of an edge in itself, and this property is the basis of many of the edges I will outline below.
- Another way of saying “choppy markets with lots of overlapping bars” is LOW VOLATILITY.
- Another way of saying “few overlapping bars” is RISING VOLATILITY.
- Sideways markets are INHERENTLY DIFFERENT from trending markets
- Low volatility markets (on a daily timeframe) make day trading harder and swing trading and position trading easier. Think about all the “day traders” who could not trade after the dot.com boom ended.
- In low volatility trending markets (like the low volatility melt up in the stock market the last few years) counter trend trades have a DRAMATICALLY LOWER chance of working.
- Extremes in both HIGH AND LOW VOLATILITY are unsustainable and indicate a market with the potential to change character
- Bull quiet markets last the longest time. Bear quiet markets last the shortest time and arguably it is not worth developing systems for these markets.
- The highest probability for market phase following a low volatility sideways phase is a high volatility trending phase
- The highest probability for market phase following a low volatility trending phase is a high volatility trending phase in the opposite direction.
Excuse my shitty drawing, but in the broad strokes this is what the different market types look like. Obviously designing a system for any one of these market types overall is doable. A 5 year old could see that building systems for sideways markets should be based around the fundamental principle of buy low-sell high, and that in a sideways quiet market scalping is going to be better than trying to hold for a bigger move. A 5 year old can also see that building a system for bull quiet markets (what we have now) is very very different than building a system for bull volatile market. As a general rule the systems we build are a reflection of our personality. Extremely smart people (like my mentor Ivan) tend to build incredibly complex systems with many moving parts. This is great for him and allows him to trade them with very high levels of efficiency, as it is a closer match with his psychology, but objectively adds nothing to the overall system performance. Quite often you see this phenomenon with highly intelligent value investors also. People who are extremely experienced at market flow and philosophically without serious psychological issues can operate with a far greater degree of discretion and intuition, and this is why some of the very best world class traders claim to have no method at all. They do have a method, it is just hard to see.
DIFFERENT MEASURES OF VOLATILITY AND CHOOSING ONE
The seminal masterwork on Volatility is by Professor Benoit Mandelbrot (RIP) and it is something that every serious trader should read.
There are pros and cons to all these measures. Also volatility for an intraday trader is very different from what a daily chart or stock trader would measure and daily volatility measures are of limited use. In my experience the ideal measures of volatility in a practical sense are in comparison to the previous 100-200 bars of data.
Method – Visual
Obviously this is a highly subjective method, but the principle is clear. Once markets start getting choppy they tend to remain choppy for a long time. Once markets break out from this choppy action they tend to be easier to trade, and stay this way for quite some time. If you look closely you can see that the part I have labeled “low volatility” is in fact a small range inside period on a higher timeframe. This is the market theory underpinning the most fundamental of Ivan’s setups. Al Brooks has an excellent method for short term trading, when there are many choppy overlapping bars he stands aside until the market starts getting easy to trade again. There is a lot of wisdom in this. Markets are not easy to trade all the time.
Method – Average True Range.
You should note that ATR can give a misleading view, because it is measuring the actual distance the market moved on average. As price goes up, obviously the same move is a lower move in percentage terms, and this is addressed in Ken Long’s Volstat Indicator, which converts ATR to a percentage of price, then adds a 100 period 1 standard deviation bollinger to it, to show in an objective sense whether volatility is comparatively high or low compared to the last 100 bars. Another alternative is using ATR crossovers, where you plot a short term and a longer term ATR and volatility is considered rising when a short term crosses above a long term ATR. You should note that since ATR is calculated by averaging closes in the past it is lagging, the predictive component of this indicator comes from understanding the phases of the market and that high volatility follows low volatility as naturally as night follows day.
If you were a stock picker this type of measure would be fine for classifying market type. We can see that as a general rule Bull Quiet markets are a stock trader’s dream run, and that by monitoring overall market volatility in an objective fashion we can identify periods of historically extreme low volatility where it is best to reduce risk and periods where volatility spikes where we want to be out of the market or trading a different system altogether.
Obviously our current low volatility bull market is very similar to the previous low volatility bull market of 2006. Pullbacks in a low volatility market tend to be shallow and buying strong stocks at a market pullback would be a strong edge. In fact designing a system for just this type of market alone would be EASY! RSI, Stochastics, MACD – all would work fine in this sort of market. The only thing is, this system would fall completely apart when the market classification changes from bull quiet to something else. If this is your goal (building a system for Bull Quiet Markets like the one we have now) you should have a trigger for stopping use of the system.
Method – Standard Deviation/ Bollinger Bandwidth
Since the calculations for Bollinger Bandwidth are based on the standard deviation of the last X closes, these two measures of volatility are virtually identical. There are inherent mathematical problems with this calculation because it is calculated on the SQUARE OF THE VARIANCE FROM THE MEAN. Because of the nature of squaring numbers once the average of standard deviation over, say 20 bars rises, it will not come down straight away. There are various proposed fixes to this including “standard error bands” (google them). As a general proposition standard deviation is an extremely sensitive measure of volatility as opposed to ATR which is badly lagging. It is very useful for VOLATILITY BREAKOUT SYSTEMS where an uptick in volatility from a historic low is a strong indicator of increased volatility in the future. As an aside this is a property of many complex systems, including the wind pressure in hurricanes, and the hydraulic pressure around a boat propeller.
Some points about this measure of volatility
- Like all robust concepts, the actual parameters still work within a large range. Anything from 12-40 will give acceptable results and 20, the default on most charting packages is fine
- The best use for this measure is not as a market classification but as a precondition to scan for stocks or markets that are statistically at unsustainable levels of low volatility and likely to break out. Extremely favorable risk/reward opportunities exist at these points
- Pattern based setups and classical charting patterns have dramatically increased odds of working during the rising volatility phases
Method – VIX (or equivalents for other markets)
The VIX is calculated based on implied volatility of front month index futures, and in my opinion is more useful as a component of a trading system for a given market type than as a classification of it’s own. The reason is that VIX can spike impossibly high, and fall just as fast. Foolish people are always doing things like drawing trendlines and calculating indicators on it, without understanding the true nature of the VIX is not a market but a mathematical abstraction. You can see that in QUIET BULL markets where counter trend trades are statistically unlikely to work, that going long the market at VIX extremes is a significant edge. The expert on VIX is Bill Luby and his blog has many useful insights.
Method – SQN
This method was invented by Van Tharp for objectively measuring system performance, before it was discovered that this is a useful measure of overall market type. I also find it useful as a measure of trend smoothness at lower timeframes, and you can potentially think about using it as a component in your trading systems to preselect the smoothest and easiest to trade trends. The formula to calculate SQN is:
SQN = root(n) * expectancy / stdev(R)
When calculating SQN for a market instead of for a trading system you substitute the average change in price for expectancy. This is the latest from Van’s website (and copyright vantharp.com) – I recommend readers taking a look at his weekly emails if you cannot find the indicator for your charting package.
************************* Mole comment ***********************
I would like to add a bit more detail here if I may (which I obviously do), in particular as SQN is a very important measure affecting all aspects of system trading. Let’s go back to ‘expectancy’ which is a common measure in itself and as Scott shows above is in fact one component of the SQN formula:
Expectancy is very simple – it’s your profit percentage per win multiplied by your win rate minus your loss percentage per loss multiplied by your loss rate:
Expectancy = (Win % * Average Win) – (Loss % * Average Loss)
Expectancy tells you what you can expect to make (win or lose) for every dollar risked. Casinos make money because the expectancy of every one of their games is in their favor. Play long enough and you are expected to lose and they are expected to win because the “odds” are in their favor.
You have a system that wins 30% of the time. When it wins it nets you 5R while losing trades lose 1R:
(0.3 * 5) – (0.7 * 1) = 1.5 – 0.7 = 0.8
So even though this system loses 70% of the time over time you can expect to make 0.8R on each trade. As you now understand R this also means that if you risked $1000 on each trade you can expect to make $800 on each trade on average (not over three trades but over hundreds).
Measuring expectancy alone however is insufficient. Opportunity is another concept that is often forgotten. Let’s assume you have the same system as shown above (i.e. 0.8R expectancy) but it only triggers 10 times per year. Let’s disregard the fact that this is too small a sample size for a moment. Instead let’s consider that taking such a small amount of trades per year will not bank you much coin. So clearly the frequency of trades and the average standard deviation need to be factored in order to define the amount of opportunity. Given the same expectancy a system that triggers 100 or 200 times a year is clearly preferable to one that only triggers 10 or 20 times.
Which brings us to SQN – system quality number – which was developed by Van Tharp and is used to evaluate the overall quality of a trading system. The formula once again:
SQN = root(n) * expectancy / stdev(R)
root(n) – the square root of the number of all trades
expectancy – as shown above and measured in R multiples
stdev(R) – the standard deviation of your profit/loss R multiples
Usually a SQN score of between 1.6 – 1.9 is considered poor but tradable. 2.0 – 2.5 is average. 2.5 – 2.9 is good and anything above 3.0 is deemed excellent.
Given the above we have a system that makes 0.8R per trade and let’s assume the standard deviation is 2.5R and that we make 100 trades in one year. The SQN of this system is:
SQN = root(100) * 0.8 / 2.5 – 10 * 0.8 / 2.5 = 3.20 (which is excellent)
However if you would make only 25 trades per year with this same system the SQN would drop down to 1.6. Barely tradable due to lack of opportunity. The higher the SQN the better your system and the easier it gets to meet your trading objective with position sizing.
********************* End of Mole comment *******************
Stockpickers should note. We are, by definition, closer to the end than the beginning of the bull quiet market. The previous bull quiet market lasted 5 years, and the current one has lasted 5 years. Nobody can predict when this will end, but there are really only two possibilities. Going out with a bang, on increased volatility like the dot-com mania, the bitcoin mania, any mania you want to name, or going out with a whimper like the last great bull market ended. In any case the clues as to changing market type will be present for those who are alert, and overwhelmingly the odds for the next market type we experience (but this could be years in the future – nobody has a crystal ball) will be either BULL VOLATILE or BEAR VOLATILE. Successful traders over the last 5 years will need to adjust their style or face ruin.
DO I ABSOLUTELY NEED TO CLASSIFY MARKET TYPE BEFORE BUILDING MY SYSTEM?
No, actually you don’t – there is a workaround. Particularly for short term systems and FX/Comoddities systems you can build into the system inherently that it will only be active in certain types of markets. If you are preselecting for a trend on multiple timeframes, then you know you will only be trading trending markets. If you are looking to only trade bollinger band extremes where volatility is not at historic lows or historic highs then by definition you will be trading markets you can classify as “sideways normal”.
How do I classify whether a market is trending?
There are many ways to do this, from simple to complicated. A short list below
- A long term moving average like a 200 SMA or 200 EMA
- A higher timeframe like weekly or monthly charts
- Classical charting definitions like a bull market making a series of higher highs and higher lows
- Ken Long’s Stretchstat concept, which involves calculating how much price is above or below (in percentage terms) the 200 SMA and overlaying a 60 period lookback 1 standard deviation band upon this. His idea is that markets are trending when they are spending more than usual time above the 200 SMA and vice versa. This works quite well
- Pick a series of moving averages, preferably exponential and define the market as “trending” when all of them are in the correct order from lowest to highest or vice versa
Choosing a Market Edge
I’m going to preface this by saying that most of you already know all the market edges you will ever need. There is absolutely no need to obsessively complicated edges and my experience is that simple market concepts, around for hundreds of years, are the most robust and the least likely to be curve fitting. This is a list of edges off the top of my head that could easily be the basis for complete trading systems.
- In trending markets pullbacks to a moving average (of your choice) are an edge
- In trending markets pullbacks to a trendline are an edge
- In spike and channel markets (channel) Buying at the lower channel with a target at the upper channel is an edge
- In sideways markets buying at support and selling at resistance is an edge
- Market Sentiment measures are an edge, but only at extremes
- In sideways markets that are not at extremes of low volatility buying at the lower bollinger and shorting at the upper bollinger is an edge
- Confluence support holding (where you have support on different timeframes and different methods) is an edge
- In sideways (trading range) markets where the higher timeframes are trending the trading range is more likely to resolve in the direction of the higher timeframe trend.
- In sideways markets that ARE at extremes of low volatility breakouts (closes outside the bollinger) are statistically likely to continue
- Multiple timeframes are an edge. ie Trends are strongest when they exist on daily/weekly/monthly and intraday timeframes
- In low volatility environments counter trend trades are a negative edge. Stated another way, in a low volatility uptrend getting long once you see a valid short setup is an edge
- Sector Rotation is an edge
- Intermarket Comparisons (Dow Theory) is an edge and discrepancies between related markets (gold v silver for example) often happen at turning points
- Classical charting patterns (Things like double tops, retests, triangles, flags) are an edge in certain environments. Ivan’s patterns are objective definitions of these sorts of things.
- The best time to trade counter trend (short) is on a retest of the old high. However applied indiscriminately this is a negative edge, most top picking exercises in a bull trend will fail.
I have never seen a good system that is not built around simple, demonstrably provable and universally accepted principles of market price action that virtually all traders know!
Now what you should do is pick one simple concept and build a system around it. I’m going to show you an example of how to test a hypothesis and build up a system from a raw concept using Mole’s market lens, which many of you use. I’m not guaranteeing that this will work, in fact this is the first time in my life I’ve turned my mind to the concept and I want to illustrate the mental process involved.
Mole uses both 60 min and daily charts with a 25 period and 100 period bollinger and SMA. On the chart below the blue solid line is the 100 period bollinger and the blue dotted line is the 100 period SMA, while the red lines are the 25 period SMA
Let’s build a system around low volatility sideways markets. In these markets both support and resistance are more likely to hold, so a reasonable hypothesis to test is the following:
In sideways quiet markets on the daily timeframe, should we fade (trade opposite) of the 25 period bollinger on 60 min timeframe where market is also sideways and volatility is normal or high? Is this an edge?
The first thing to do is be a scientist and generate a hypothesis, do a quick test and see if it bears turning into a theory with more testing. You might have many failed hypothesis’s and should test them quickly. Spend an hour, no more, and decide if something bears further investigation.
Let’s bring up Mole’s other chart, using the same period, from 9th October to 21 November. Judging by eye (this is just a hypothesis test) I have marked the two periods of sideways markets which are not extremes of low volatility. I’ve marked the touches of the bollingers with green arrows.
Now visually, there is something there. The bollingers appear to be respected, and with the right initial stop choice, and the right campaign management we might have something there. The big question is how do we choose our initial parameters to test with.
Pay Attention – This is important
As a general rule we are looking to make at LEAST 2:1 and preferably 3:1 risk to reward on our good trades. So it’s quite obvious that an example of a good trade is buying at the lower band and selling at the upper band. The average width of the bands in those period in the boxes is approximately 75 pips (no need to be exact) therefore a good initial parameter to test with would be approximately 1/3 the width of the band, which happens to be almost exactly the same as the 14 period ATR which averages 25 pips. For consistency sake we will test with an initial stop of 1 ATR(14)
How do we know what targets to use?
Well this is fascinating, because on edges that are STRONG you don’t actually change the overall return that much by changing exit parameters. You do, however dramatically change the tradeability and quality of systems. You want to eyeball the sample and guesstimate the winning percentage of getting 1R, where R is the size of your stop. In other words I’m guessing what percentage of the time you are going to risk 25 pips to gain 25 pips. Here I’m going to just roughly guess the result as W L W W W W W W L ie 7 wins 2 losses. I’m going to add in an extra couple of losers just to random things out a little and get to a rough guestimate of 63% wins. You should know that NOTHING in the real world is better than 65% in the long run. If I trade this for 100 trades at this rate I’ll have 63R from winning trades and -37R from losing trades giving me 26R overall or a guestimated expectancy of .26R per trade. That is bang on what you should expect from an unoptimized system, and with some work we should be able to get this much much better.
Now NONE of this is real or particularly accurate but it’s a nice place to start.
Now let’s break out a pencil and paper and do a real test, one for exiting at 1R, and one for exiting at 2R. No need for computer backtesting, and in fact it is counter productive. If you operate on the principle of “like things behave alike” you can look for repeatable situations. Rather than curve fitting you approach from market principles first and work backwards. Based on what I know about markets I think it is highly likely that when the daily market is going sideways in low volatility and the 60 minute is going sideways in low volatility (without extremely low) then the bollinger band is support that should hold, most times.
We had 9 trades, 8 wins, and all 8 of those made at least 2R. That is fantastic, returning 15R in total over 9 trades is rockstar performance. If you can do even 1/4 as good in the long run you are going to be rich. Sadly but obviously however this is not a statistically significant sample. This is cause for further testing on exactly the same basis to see if the edge is real. After you ascertain if you have a real edge you can go on to optimize your system for system quality number and build a suitable campaign management and exit algo around it. I’ll cover that tomorrow, it gets quite heavy.
What do you do at this point? Try exactly the same thing, and keep building until you have 50-100 trades, done just like this, with pencil and paper. It doesn’t take long, it would take you 2 hours at most to do 100 trades across different markets and times.
So In Conclusion
- Don’t try to build a Rube Goldberg machine.
- Objectively complicated systems don’t necessarily test better than simple things.
- Choose a market type and an edge which you think is real based on WHAT YOU KNOW ABOUT MARKETS, not based on data from a spreadsheet.
- Choose an initial stop to test with that you can see a good trade being at least 2:1 and ideally 3:1 risk reward.
- Test with pencil and paper, don’t engage programmers
- Once you bang out enough W/L simple pen and paper testing to have confidence in your edge, you can go on to optimize campaign management and exits, which I cover in exhaustive detail tomorrow.