Building Trading Systems – part 4 – Entry and Exit techniques and system optimization
This is Scott Phillips. I’m taking over from Mole for a week, attempting to impart what I know about system design and trading for a living.
Yesterday, to recap, we talked about choosing an edge based on a known property of markets that you have an affinity with (everybody has favorites) and working out which market types it works in and which market types it does not. If you don’t know which market types your system works in the best you can ever hope for is mediocre performance, which comes down to small edges, long drawdowns, and systems not suitable for trading at R values of 2% or above. If you think your edge is universal and works all the time you are being foolish. Markets are hard to beat because they change constantly in fractal ways. By aligning your approach with the current market type you not only increase your overall winning edge but your edge becomes REPEATABLE and CONSISTENT. If there is one thing the pros in any field have it is repeatability and consistency. Any weekend golfer can hit a birdy but Tiger Woods can do most of the time.
Some other edges I forgot to mention
- Opening gaps are an edge
- Breakouts are an edge
- Failed Breakouts are an edge
- Implied Volatility is an edge
- Market Internals are an edge
- TICK and TRIN are an edge
- Mole’s Zero indicator is an edge
- Sequences of unbroken series of highs and lows is an edge
- Consecutive Up/Down closes is an edge (but a thin edge)
- The shape of the most recent candle is an edge
Which of the following 2 edges do you instinctively think performs better?
- Edge A Trading a Donchian Channel breakout on a 60 min chart?
- Edge B Trading a Donchian Channel breakout on a 60 minute chart only in the direction of the higher timeframe trend where the 240 minute, daily and weekly charts were trending AND where volatilty, measured as bollinger bandwidth has painted the lowest low in 100 bars in the previous 10 bars?
Which of the 2 edges do you think will be more consistent? Which of the two edges do you think will have longer streaks of winning trades? Losing Trades? Which of the 2 systems do you think is more likely to fall apart if the market type changes?
I see many people in the comment section defending their existing systems and proposing random stuff they read on the internet. What I am showing you here are fundamental truths about market systems – NONE OF THEM, none of them at all, work all the time. None of them work the same, or just as well in trending or sideways markets, or low and high volatility markets. You can do decades of backtesting, and because of the skew of the last 30 years containing mainly bull moves, you will get backtest results which will not match up with the reality of forward testing. I am also showing you some fundamental truths about markets in general and trading
- Systems based on real market principles are far more likely to work and test better when they do than those which are not
- Systems optimized for a particular market type produce results orders of magnitude better than “one size fits all” systems
- If you have a system which works it will work DRAMATICALLY BETTER once you understand what market types it does not work in!
- You might have 10 bad system ideas before you have one good system idea. Therefore it is better to test in a minimal way to separate wheat from chaff
- You should not use price based indicators to confirm price based indicators – It’s like asking your Mother if you are handsome 😉
I see in the comment section of the previous post people complaining that the methods of testing targets are arbitrary, and yes they are and those are NOT your final exit parameters. The method of “quick testing” I advocate for preliminary testing of an idea allows you to spend an hour instead of a month to quickly test an idea and decide if it is worth further investigation. There are a lot of blind alleys in system building and because human nature is to get attached to our own ideas we don’t want to let them go once we have spend a month on them. Let’s assume that you have an idea you think might be good, preliminary testing bears that out, now we have to get into the weeds and spend a lot of time building a system around it. This is non-trivial, it will take you a few weeks minimum, so it makes sense to do a lot of quick paper testing to separate the good ideas from the useless ideas before you get to this stage. Even if you are a good programmer, I still advocate pencil and paper testing initially for everything. It gives you a deeper understanding of the edge at the initial stages, and allows time for your market intuition to bubble up pertinent insights. Backtesting is a useful technique, but most system builders do WAY TOO MUCH OF IT. Of my two systems which Mole provides. Crazy Ivan was developed with extensive backtesting. Heisenberg was built with NO BACKTESTING AT ALL. Absolutely none. Zero. Objectively, on any measure you wish to name, Heisenberg is the superior system.
Entry Techniques – Pros and Cons
Conceptually you have 4 choices
Entry Technique 1 – Entering on a Stop or StopLimit when the market moves in your favor
The advantage of waiting until the market moves in your favor is that it increases the edge ever so slightly before you get in. Also, if you can place your entry point where other traders place their exit point you can get a little boost from the other guy getting his stops run. This is a very good choice for 5 min chart index traders, also a good choice for traders trading trending markets. One good point about using this technique is that if you are entering on the break of a high (to go long) of a bar, the obvious place to place your stop is just below the low of that bar. Your system will benefit from a logically chosen and not arbitrary stop (though you may want to add a minimum stop distance, abnormally small stops are statistically likely to be hunted as the market noise overwhelms signal. For intraday trading on 60 min charts my experience is that stops around 1.5 times the 15min ATR(14) are optimal and have a better expectancy (Thanks to my friend Frank Bormann for extensive research on this). One particular thing I have noted is that the Asian session FX markets contain substantially more noise and less signal, though remaining very tradeable (most of my trading is intraday FX during Australian market hours). I make my stops several pips wider during the Asian session, to make up for low volume and larger spreads.
This technique is totally unsuitable for trading range bound or choppy markets, it will get your ass handed to you. The disadvantage of this method is that you are entering later, trading some profit for greater certainty.
See the “cheat sheets” above for more detail.
Advanced Technique (Ivan Krastins) – Entering on the Break of a Candle which is confirming your view
This is a powerful and useful technique for entering a trade and filtering many bad trades. Any hammer candle (see cheat sheet above) is a failed attempt to drive the market down (and vice versa with it’s inverse the shooting star). In a strong bull move it is a fundamental and demonstrable principle of markets that most attempts to drive the market down will fail. Every time the bears attempt to drive the market down, they will be forced to cover their shorts at some point. A significant number of them will cover on a break of the previous high, driving the price further up. Especially after hours, even more traders will wake up to the next trading day, find their positions moved against them, and cover in a panic, driving prices further up. This technique works on all timeframes, but is particularly potent on daily charts. Be aware that it has little value *except* in a two situations. Firstly, a strong trend (see previous post for ideas on how to filter for strong trends, you could look for multiple timeframes, high SQN, moving averages in alignment, above a long term MA, making higher highs and higher lows), and secondly, at support, for example at bollinger support or trendline support. This technique is the basis for a system which I currently have in development which so far tests extremely well. Ivan also has setups based on this technique called the Trend Trade, which I simplified and modified for the CrazyIvan system. See the cheat sheet above for a full discussion.
Example of How You Might Build A System Around This Principle
This is not a current system of mine, just a random idea which I am highly confident would work as a system. I hope you are all getting the concept that because I am basing my systems on things I know are true about markets they are far more likely to be workable as systems. People who build systems based on backtests are in almost every case curve fitting. It is simply easier to start with the solution and work backwards!
Idea: In the very strongest and smoothest trends an early EMA is going to act as resistance. I spend a few hours looking at various “strong trends” with many EMA’s up on the screen (6,8,10,12,14) noting the SQN (measure of trend strength) of each one and looking for patterns. I settle on the 9 exponential moving average as being a common place for retraces to stop in bearish trends which are SQN(100) -.5 or less. After looking at preliminary results I can see that around half the time my edge works, sometimes making for big winners where my initial stop is never touched. This looks promising and I look at the losing trades from my small sample of 50 trades and go back and look at the trend direction on higher timeframes – I note a pattern that half the losing trades come from times where the daily and 60 min trend are in opposite directions. By filtering so that I only take trades with multiple timeframes aligned I increase my edge. If you have an edge which is marginal, quite often you can switch it into “acceptable” territory by using this technique.
Example – Bollinger Breakout
Entry Technique 2 – Entering at market when your system parameters line up.
As a general rule I do not favor this technique, but very well composed and emotionally serene people may find it suits them. My experience is that I become slightly anxious trying to get the best fill and it is better for my emotional state to enter on limit or stop
Entry Technique 3 – Entering at a Limit order>
As a general principle for sideways markets entering on a limit order is optimal. I make it a personal rule never to chase the market, and if my limit orders are not filled I try and find acceptance around that. Chasing the market, even by one or two ticks, over time eats away at your account.
Entry Technique 4 – Entering on bar close
This is particularly good for traders who wish to base entries on daily charts and not day trade
Concluding Thoughts on Entries
Don’t get too wrapped up in entries. In systems for range bound markets lean towards entering on a limit. In systems for trending markets you have a choice which depends on your personality. If your edge is shallow you can increase it by adding an additional requirement for a nice looking candle, or candle pattern before you enter. A deep understanding of price action reading in context can help here, and for that I recommend Al Brooks series of videos and books (though not his first book which is incredibly poorly written and recovered in his later 3 volume series). Also Ivan Krastins, member of this community, has many deep insights about the nature of price action, and his site is worth a visit.
Chuck Lebeau Concept for preliminary testing of Entry Techniques
This is not a technique which I use personally, but other system designers I know use this to quickly test and filter whether a given entry technique is useless or has validity. His idea is to estimate the period you want to trade, and test time triggered exits after similar results. For example if you have a system where most trades last 1-4 Bars (like for example CrazyIvan) you might want to test Period1 Period2 Period3 Period4 and Period5 exits. A strong edge should be around 55% in this raw, unoptimized state.
Exit Technique – The Difference Between Professionals and Amateurs.
Amateurs think about entries, professionals think about exits. Amateurs are always looking for a better entry technique. Professionals know that nothing in the markets gets really certain, and the biggest difference to system performance is in the exits.
Most of the methods which are recommended by the “experts” are very wide trailing stops, which give back way too much profit at the end of the trade. It is quite heartbreaking to watch profit in a winning trade evaporate, and this can affect trading emotional state going forward. Many of the old school trend following systems use 3 times the 7 day Average True Range as a stop and in my opinion this is way too large.
You have big decisions to make
- How wide is your initial stop?
- How soon do you move your stop to breakeven or close to breakeven to protect profits?
- When do you bank partial profits, if at all, and why?
- How loose do you trail a stop?
- Do you take profits on a target or a trail?
All of these decisions have a lot of moving parts and many permutations. Most of us get confused. Here is how I personally answer those questions
1) How wide is your initial stop? I do my preliminary testing either on an ATR based stop or a break of the high or low of the setup candle. For smaller timeframes where there is more noise: signal ratio initial testing of 1.5 times the 15 minute ATR is a good enough place to start. For testing scalping systems on highly liquid markets (think bonds and eminis) the standard exits to test are 4 tick stop 4 tick profit and 4 tick stop 6 tick profit.
What I do is measure the MFE (maximum favorable excursion) of my winning trades and plot a histogram of them using a spreadsheet (google spreadsheets is fine). I use COMMON SENSE when I do this, so it is not suitable for computers and software. What I mean is that lets say I have a trade which makes 3R and then pulls back to breakeven, and then shoots up to 5R, in the real world I would not still be in that trade so I would count it as a 3R MFE not a 5R.
You want to measure 3 things
- Maximum Favorable Excursion of winning trades defined as trades which make over 1R
- Maximum Retracement as a percentage
- Maximum Retracement in R (using common sense)
Add them to a spreadsheet, then sort them and plot as a histogram. I have done this with my winning trades of the last 2 weeks as an example here Your sample size should be at least 50 winning trades to be statistically valid. These are the winning trades from the 18 trades I personally took over the last 2 weeks.
Points to Note:
The more your edge is based on a real property of markets and not stupid curve fitted bullshit the easier it will be to optimize for exits. The more it is based on ONE SINGLE PROPERTY OF MARKETS AND NOT A BUNDLE OF THINGS YOU TRY AND USE ALL THE TIME the easier it will be to optimize. You can see very clearly why I insisted on building your edge based on properties of markets, rather than statistics showing you have an edge based on backtesting. Nice smooth easy to optimize curves? Get it? This is a simple trend following system based on a volatility breakout which I trade every day. Even with a very small sample size it is obvious that this is a real system that behaves in A REPEATABLE AND PREDICTABLE WAY. REPEATABLE AND PREDICTABLE is going to equate to higher system quality numbers. Random looking but with an overall edge is going to equate to shit system quality numbers.
Here we can see that of 11 winners 4 of them made 1.2-1.5R. We also see the nice smooth gradient after 1.2R up to 6R. Some things should be immediately obvious. Optimizing my exits to try and catch 5 and 6 R winners is obviously suboptimal for this system. However it seems quite reasonable to try and catch a decent chunk of the 4R and above winners, which happen about 36% of the time.
One other thing to note: We can see that the median (the middle) of the range of winning trades is approximately 2.5R. This tells us that THE INITIAL STOP IS PRETTY GOOD. Our normal winning trade is 2.5R so that means we have a risk/reward ratio which is better than 2:1
Let’s test a few arbitrary limit exits. If our entry has potential most of the exits (except for the extremes) will look similarly good with small variations. This principle is from Eckhardt and is very useful. If you have a limit exit at 1.5R testing extremely well but everything else testing negative or marginal your edge is garbage and needs to be rethought.
What is very clear is that exiting on a limit at 2.5R would maximise the R return, and thus the expectancy over the 18 trades. However that is a HUGE MISTAKE. We would go from having 11 out of 18 winners (61%) to having 7 out of 18 winners at 38%. As a general proposition win rate is the least important part of a trading system, but a system with 62% losers is going to have to endure huge series of losses and dramatic drawdowns, meaning that it is going to be unsuitable for trading with R values over .5%. I prefer to trade high quality systems with very shallow drawdowns than shitty systems with long and deep drawdowns. So should you.
The effect on expectancy on different limit exits is shown below, assuming all losses are -1R. You should be able to take the best result and improve on it substantially by optimization. By way of comparison my production systems, optimized, test in the 3.7 range on SQN(100). Here we see that a limit exit of 1.2R is going to get us .29 expectancy and 3.17 SQN(100). This is not bad, pretty damn good actually. In the production system the optimization takes this to Expectancy .5 and SQN(100) of 3.7. So these initial limit exit numbers give us a benchmark of baseline performance and let us know where is the sweet spot for banking partial profits.
This is extremely important. Pay attention.
Because the sweet spot in SQN terms is exiting on a limit at 1.2R we can smooth the equity curve and reduce the standard deviation by BANKING PROFITS AT THE SWEET SPOT ON THE LIMIT EXIT SQN CURVE. This is critical, and needs to be absorbed. You could bank 1/4 or 1/2 of your position at this sweet spot, or more importantly you know the different numbers you should be testing for on your forward test. You can then either go back through your last trades, or walk forward testing a new series of trades, using a spreadsheet to work the difference in different exit strategies on overall SQN.
Every system is different! Once I understand objectively how my entry behaves I can now use my spreadsheet to play with various combinations of partial exits and trailing stops initiated at various points, depending on what I want to achieve.
On Surviving Retracements
The maximum retracement you can stand bearing has to be closely matched to your personality and the level of psychological trauma you have previously suffered in your trading life. It might be mathematically optimal to allow a 3.9R winner to evaporate into a -1R loss, but in the real world those kinds of equity swings play havoc with your ability to trade at a high efficiency. There are those who say “just man up and follow your rules” but invariably people who are dogmatic about that stuff have rules which bank comparatively early where it is emotionally comfortable to do so. If you are going to shoot for the big winners there are both emotional and technical advantages to banking some profits along the way.
Question: Based on this histogram – where do you think I should bank some profits? Why?
As a general rule if you want to catch enough of the big winners to justify optimizing to catch those winners (which by definition will be suboptimal for small winners) you have to be prepared to endure at least a 50% retracement of the move at some point. Because of this there is an enormous advantage to trend following systems to entering BEFORE a rise in volatility, rather than the conventional wisdom breakout trades which often get you in quite late. The alternative if you wish to build breakout systems (which are good systems) is to filter the breakouts for only the STRONGEST breakouts, which by definition happen after EXTREMES of low volatility.
Another fundamental concept of markets is that it is EXTREMELY COMMON for markets to backtest breakout points. If you are trading any system which is relying on trend continuation after a breakout if you move your stop to breakeven too early you will be taken out enough of the time to have an adverse effect on performance. This is the perfect example of using market principles that we all know are demonstrably correct, rather than endless computer fitting.
Pay Attention – This is the KEY to designing effective exit algorithms
No one type of stop is going to give you anything like decent performance overall. The correct thing to do is to choose 4 or 5 or more different types of stops and have them in a race to take out your trade.
- Limit Exit at a target in sideways markets at resistance (bollinger,trendline, market profile)
- Multiple Closes outside the bollinger band exit (suggest 2 or 3 consecutive closes outside bollinger exit on close)
- Time Based Stop – If your trade hasn’t made 1R by x bars then exit
- Chandelier Stop – Hang from the highest price yet achieved in the trade
- ATR Stop
- Spike Low Stop – This is very valuable for strongly trending markets
- Trailing Stop – In ticks, in R or in multiples of ATR
- Sign of Strength or Sign of Weakness stop. If you get long on a breakout you do NOT want to see a strong down bar within a few bars of entry.
- Modified Spike Low Stop (inside MA) Only count spike lows which are deep enough to pierce a Moving Average or linear regression you like
- Trend Reversal Exit – If you have a favorite technique for indicating a new trend is starting in the opposite direction, you can use this as a signal to exit a trade. This is particularly powerful if you are in, for example a daily chart trade and you have a 4hr signal in the opposite direction.
- Percentage of Maximum Favorable Excursion Stop
- Parabolic SAR Stop – Welles Wilder Designed this stop which gets tighter and tighter as time goes on
- Indicator Stop – One of the most effective stops for trending markets (applied in conjunction with other stops) is a bollinger bandwidth stop
That is so important I’m going to repeat it. It is KEY to building systems.
No one stop will meet all your needs. You need at least 4 different stops and potentially many more run in tandem
Note: Having a system is not a suicide pact! You can build limited discretion into your rules. For example one of my own rules is that if the stop I am planning on placing is within a few ticks of a spike high or spike low which is likely to have stops there, then I will relax my stop by a few ticks so that I don’t get stopped out by big players gunning for stops. Another example of an appropriate discretion rule is to add an extra 2 ticks to your stop for intraday trading the Asian session to account for the greater noise:signal ratio. Another appropriate relaxation might be to place your stop behind closeby support (whatever support fits your beliefs) for extra protection
General Exit Principles
Most people place their stops too tight at the start and middle of the trade, and too loose at the end. Do the opposite
Once you get to a point in your trade where the RISK:REWARD is 1:1 or worse you should be exiting. This is extremely important.
You should be tightening your stops or flat out exiting on a limit as you get to high R multiples where the risk is not worth holding any longer. On the example below it is obvious that the 4R point is where I should be planning to start tightening my stops and be happy if I am taken out of the trade.
What am I optimizing for, anyway? Total R, Expectancy? SQN?
There are many different measures of system performance. Expectancy, Clawback Factor, Time at fresh equity highs, Dependency (% of time a win is followed by a win and vice versa), average length of drawdown, maximum drawdown.
My opinion is that the following statistics tell me everything I need to know.
- Win rate (although this is the least important thing)
- Expectancy – Total R / Number of Trades
- Expectunity (opportunity x expectancy) so .2 expectancy x 100 trades a year @ 1% R is expected 20% per year
- System Quality Number (100)
Note on SQN – calculating SQN as some suggest using the square root of the number of trades gives a false positive for prolific but poor systems. Limit the maximum value to 100. So in effect the formula is
10 x expectancy / standard deviation
An SQN of 2 is a tradeable but average system, but if your preliminary backtest results are in the low 2s for many reasons backtests dont perform like reality, you probably need to throw it away. The ratio of expectancy to standard deviation is the key thing here. Once you understand what standard deviation is you can work out how to optimize for it. Rather than repeat it just go here
If you optimize your exits to maximise SQN you will have smaller drawdowns and be capable of trading your system at higher R values, up to 2.5%. When we talk about optimizing for SQN we are really talking about optimizing for standard deviation, since expectancy doesn’t change by huge amounts. Understand at a deep level and you can improve your systems dramatically.
For optimizing the trend following system I have outlined above it is obvious I need 3 different exit.