Discover more from 50 Trades in 50 Weeks
Week 26: Pattern Recognition
Humans are pattern recognition machines. That's good, and bad.
Hi. Welcome back to Fifty Trades in Fifty Weeks!
This is Week 26: Pattern Recognition
50in50 uses the case study method to go through one real-time trade in detail, about once per week. This Substack is targeted at traders with 0 to 5 years of experience, but I hope that pros will find it valuable too. For a full description of what this is (and who I am), see here.
If you want to learn about global macro in real-time … subscribe to my daily: am/FX
This is Week 26. Fifty weeks divided by 2 is 25 … and 26 is greater than 25 … so that puts us >50% of the way through this experiment! Nifty. I have been having fun and I hope you are learning specific skills and techniques that you can put directly into practice in your trading. If you have read every single episode so far, I admire your hard work and you deserve a sticker.
The short SPY trade is back from the dead as we peaked right into mega resistance at 4300/4330 in SPX. Last week’s MSTR short is almost at the take profit already, while XME trades well in a down market. Overall, the 50in50 trades had a good week.
Here are the results from last week’s sentiment vs. confidence survey. Similar to Week One, people are looking for lower stocks and generally tighter financial conditions. The consensus was generally correct last week.
Sentiment vs. confidence (1 is least confident, 5 is most confident)
Here’s this week’s survey. Please take two minutes to fill it out! Thanks.
Now, let’s talk about pattern recognition and backtesting.
“Chaos is not dangerous until it begins to look orderly.”
- Max Gunther, The Zurich Axioms
Great traders are masters of pattern recognition. They will see a setup and recognize it either consciously or unconsciously. I remember many times after great runs of trading that I felt like I knew what was going to happen before it happened. This ability comes from the incredible powers of human pattern recognition. The problem is:
Humans are built to see patterns, even when none exist.
Apophenia and patternicity are terms psychologists use to describe the human predisposition to see patterns or connections, even where none exist. Apophenia leads to many flaws in human thinking and explains why people see Jesus on toast, UFOs in the sky, bigfoot in the woods and so on. This human bias toward pattern recognition also leads gamblers who are on a winning streak to believe they will keep winning. Even smart, logical people often feel like they are “heating up” after a lucky series of hands at a poker table.
This is also known as clustering illusion. People have a hard time believing that streaks are the result of randomness, even though random data contains many streaks!
We are wired to find meaning and significance in random and meaningless data. Apophenia goes a long way toward explaining why humans believe conspiracy theories, suffer from paranoia, and embrace pseudoscience. When you see patterns everywhere, you see meaning and connections too. Understand that you are not immune! You are predisposed to see patterns, even where none exist.
The human ability to see patterns is a critical part of our evolution and allows us to understand the world without having to analyze every single new piece of information. If we have never seen a large black cat with large teeth on the savannah, a useful evolutionary trait was to assume that its behavior and risk profile is similar to other large animals with huge teeth we have encountered in the past.
We can correctly infer that the presence of dark clouds in the sky above us represents an increased probability of rain in the next few hours. We know a hissing sound nearby means snake bite risk is higher than normal and we dramatically increase our alert level.
Evolution favored false positives over false negatives because the cost of a false positive in the wild was much lower than a false negative. For example, there is a loud grumbly noise in the bush that Caveman Kror cannot clearly identify:
False positive (Type 1 error): That sounded like a lion, I think?! I’m out of here!
Cost: Kror may have used some unnecessary energy avoiding what could have been just a random sound.
False negative (Type 2 error): Hmm, I wonder what that grumbly noise was. It didn’t sound exactly like a lion. I guess I’m good. (42 seconds later) Oh, dang, it was a lion.
Cost: Kror is dead.
Seeing patterns where there are none may be superior evolutionary behavior, but it’s not helpful in trading. Given the very strong human instinct to see patterns, how useful do you think simple eyeballing of charts, basic trendlines, and breakout patterns is likely to be? What are the odds that chart break is just a standard false positive—like the loud noise in the bush? Now add on human confirmation bias… Are you just seeing what you want to see? Probably.
This does not mean that there are no patterns in the world. If you run into heavy traffic four days in a row at a particular interchange, it makes sense to consider whether there is causation. Investigating further, or temporarily changing your route is likely to be optimal. But you need to be aware that the way humans see patterns is biased to Type 1 errors. You need to be discriminating and use a tight filter when looking for patterns. You need to consider that what you are looking at could be random.
Let’s say you see a headline on Bloomberg: “Death Cross in silver futures triggers bearish signal”. You pull up the story and see a fugly chart where the 50-day moving average has just crossed below the 200-day. Is your first instinct to sell silver? Or to investigate more deeply? Patterns like this should not be taken at face value. Most of them are meaningless and have no empirical basis. Take half an hour to pull some data into Excel and backtest the pattern. Does it have any predictive value?
When I say “patterns” that does not just mean technical analysis. It is any cause-and-effect relationship that appears to exist in markets. Again, humans tend to ascribe causality to many things that are the result of pure chance.
On the other hand, patterns like the following examples could be meaningful, persistent, and predictive:
Gold tends to go lower from 9 a.m. to 10 a.m. (maybe gold producers sell at this time?)
Whenever US rates go lower, USDJPY goes lower (Japanese investors prefer higher rates?)
AAPL tends to lead the QQQs (large caps lead indexes?)
Highs and lows are more likely on round numbers than non-round numbers (humans exhibit round number bias)
Bankrupt stocks usually rally on the open after being halted (nobody left to short and shorts wanna cover)
Two days before the last day of the month, the USD tends to rally (this is the day many corporations buy USD to hedge foreign revenues)
And so on. Sophisticated pattern recognition can be a significant source of edge when it is free from bias.
Finding and analyzing patterns
I spend a good part of my time analyzing data in an attempt to determine whether patterns have predictive value or not. Most often, the answer is “not”. Taking the time to analyze patterns and to determine whether or not they are useful for forecasting is a good way to overcome apophenia and discover useful tools for beating the market.
This is my simple four-step method for accepting or rejecting patterns:
Identify a pattern or relationship.
Generate a hypothesis.
The best patterns have some sort of underlying logic. If gold goes down every day from 9 a.m. to 10 a.m., maybe that is the window when gold producers sell. If you can logically explain why a pattern works, it is much more likely to be non-random and persistent.
Analyze the data.
Accept or dismiss the pattern.
Anyone who took a science class as a kid should recognize this as a short-form version of the scientific method. Most patterns you analyze will be worthless. You will dismiss them and move on. On the other hand, the few patterns you find that are non-random can be incredibly valuable to your future trading.
Every time you notice a pattern, reduce it to something you can test and then get to work. You don’t need sophisticated quantitative skills to do basic backtesting of simple theories. Once you backtest a pattern, you have a much deeper understanding of whether or not it is random, and you know whether to factor it into your trading decisions.
For example, I like to use moves in one market to predict moves in another market. Here is an example of how I will look at a pattern and try to determine whether or not it has meaning. This excerpt from am/FX also gives you an idea of how I pull together multiple reasons for a particular trade idea.
From am/FX on July 1, 2020
We had a rare setup at the close yesterday as US rates have dropped 8 bps in the last five days while USDJPY was up 1.3%. There have been 2610 trading days in the last 10 years and just 49 of them have satisfied the condition: (USDJPY up >1% and US 10-year yields down more than 7bps). Here is how USDJPY performed after:
USDJPY performance after two conditions met (sample = 49)
And note that USDJPY rallied from 88 to 107 in the last 10 years, so if you took any random sample it would show USDJPY going up, not down. That makes this result even more interesting. The medians are similar to the averages, so there is not a small group of instances skewing the average.
Overall, I think USDJPY is a sell based on yields, the move in gold, and USDJPY’s consistent inability to take out 108.00. Also, there was a three-day run of buying madness in NY time from 7 a.m. to 11 a.m. and there is no evidence of that today. It was probably a major rebalance into month end. So that is over, which also helps.
Note in the chart below how USDJPY bashed against 108.00 four times (four arrows) before a huge false break and then it retested the 108.00 level again afterwards (fifth arrow).
I am therefore adding a short USDJPY recommendation. You could either sell here or leave an offer at 107.75 with a stop at 108.26. With ISM and payrolls tomorrow, there is a decent chance you get done. And with Yield Curve Control on the horizon and the explosion of coronavirus cases in the US South, I doubt strong US data will impact yields much.
Note by leaving an order to sell above market at 107.75 through nonfarm payrolls, I attempt to take advantage of the noisy volatility created by an event I think is meaningless to get set at a good level on a trade I like for a bunch of reasons. Here is the chart:
USDJPY Hourly, April to July 2020
I got set on the trade the day after payrolls (at 107.75) and USDJPY went pretty much straight down.
If you want to level up your global macro and trading XP every day, and see how I generate actionable trade ideas in real-time, click here to subscribe to am/FX. The price for new subscribers goes from $490 to $590 at the end of August—sign up now and lock in $490/year forever. Click here to subscribe.
Backtesting is an entire field of quantitative research and there is considerable complexity involved. I am not a computational finance or applied math expert, so I like to keep things as simple as possible. I come up with a theory, and then I test it. I don’t tweak the parameters or snoop around until I find something useful. I just go in, test, and get out. While a full course in backtesting is beyond the scope of this note, you don’t need a degree in financial engineering to conduct basic backtests of patterns you identify and ideas you come up with.
When testing your hypothesis, be aware of a few things:
The law of small numbers. You need a decent sample of observations for your analysis to mean anything. If you see that TSLA stock went down the last four Aprils in a row, that’s meaningless. If it went down 33 of the last 41 Fridays, that might mean something. While there is no hard rule for legit sample size, any study using less than 30 observations is risky and likely to be less reliable.
The harder you have to look, the more likely whatever you find is bogus or biased. Let’s say you want to see how the stock market performs the Monday after a 3% drop on Friday. You find nothing interesting. So then you test how it performs after a 4% drop on Friday. Still nothing. Then, you up the threshold to 5% and find the subsequent Monday averages a 2% further fall. Then you test, “What if stocks fall 2% or more Thursday AND 5% or more Friday” … The more you mess around with your parameters, the more likely you are to find “interesting” results. This is called “p-hacking” in the research business. You keep tweaking the inputs until you get an interesting result. That is not good research.
Don’t torture your data in an effort to make it confess. Keep your analysis simple. For the best ever and super simple explanation of how p-hacking, snooping and data-mining work, see “xkcd green jelly beans” at the end of today’s note.
Be aware of the trend in your data. If you do any study of S&P 500 data since 1930, you will generally find that bullish strategies perform well and bearish strategies perform poorly! This makes sense since stocks have gone up a zillion percent in that time period. Similarly, you will find it easy to “discover” bullish NASDAQ or bearish oil company strategies. The secular trend in the data is an important driver of the output of any strategy you analyze.
No matter how well something worked in the past, there's no guarantee it will work in the future. In a world of infinite data, many relationships, and a huge number of sophisticated analysts, people are going to find strategies that worked in the past. If you have a strong opinion on why the strategy is likely to work in the future, the value of your analysis is higher.
For example, Turnaround Tuesday is well known and has existed for many years. It is founded on a reliable and repeatable pattern of human behavior and a persistent fear and greed cycle that repeats around weekends, even if statistically savvy investors know about it. Also, as a short-term strategy, it is fairly expensive to execute (in terms of transaction costs) so large institutions are unlikely to quickly arbitrage it away.
Don’t build regression models unless you know what you are doing. Regression models can be useful but often require sophisticated knowledge to avoid data mining, overfitting, and other errors.
Most patterns in finance are random. You need to find evidence and use logic before accepting a pattern as meaningful.
The stock split pattern
Stock splits are a strange phenomenon that drives EMH proponents crazy because splitting a stock 2-for-1 should have no impact on the price of the shares. In theory. If I have one dollar bill, or four quarters, I don’t expect the four quarters to sell at a premium to the dollar bill—it makes no sense! But things don’t always have to make sense in markets. It’s not a perfectly efficient world; it’s just a bunch of humans buying and selling stuff and humans are not particularly logical at an individual level, or in aggregate.
The best explanation for why a stock split would increase the price of a stock is that the split news attracts attention to the stock. By definition, the stock is usually near the highs and there is a bullish story around it, so more attention = more buying.
Here is the abstract of a paper on the topic:
In this research I study whether stock splits attract market’s attention by exploring how investors are trading around event announcement dates. By employing high frequency intraday trading data from NYSE Trades and Quotes (TAQ) database I compute net abnormal buying around split announcements. The empirical tests on a matched pair sample of splitting and matching firms show that stock splits serve as attention attracting tool and investors are buying abnormally more around the announcements. Additional analysis confirms this finding – abnormal buying is significantly higher for larger splits.
I have noticed lately that not only do stocks rally on the split announcement, but they sell off after the split in what looks like a “buy the rumor / sell the fact” pattern. This would make sense as people buy the stock on the split because they think other people will buy the stock on the split (greater fool theory) and once the split happens, they have no reason to hold the stock anymore.
I asked Justin to take a look at the price action of stocks into and after the split date to see if this pattern is real or just my imagination. Here is the result:
Performance of well-known stocks that split in 2022
The sample size here is only 9 stocks, so caution is warranted. Not a great sample size! I have seen better patterns than this one, but I am using this one as this week’s trade because it’s relevant and timely and my belief is there is enough logic to the pattern that it’s not random. My conviction on the trade is 5.7 out of 10.
TSLA splits tomorrow (24AUG) and trades post-split 25AUG. As such, selling TSLA here (888) with a stop at 914 (above the two recent opening gaps) makes sense based on this pattern. The effect is only good for a few days, and Powell speaks Friday, so the safe trade (and what I will do for tracking purposes) is square up at the close on Thursday, August 25. We don’t want random Powell risk on a pattern like this.
In real life, you would want more of a thesis than a simple pattern like this. Perhaps you were already bearish TSLA and were waiting for a rally and now you got the rally and you now you also have this post-split pattern working in your favor. The pattern is another planet in line that helps you fine-tune your tactics and optimize your execution timing.
Backtesting might sound daunting if you’re not a quant, but trust me, it's easy. Don't be intimidated by Excel - if you spend a couple of weeks trying stuff and Googling how to make Excel do something… Before you know it you'll be more than capable of quickly testing theories against prices and data. You don’t need crazy math skills to do your own backtesting.
Use the scientific method to test patterns. Don’t optimize parameters. Don’t snoop for results if your initial idea turns up nothing. Be honest with your analysis and remember that humans are built to see patterns, even where none exist.
Further reading: Fooled by Technical Analysis is an excellent learning tool if you want to know more about the fun and perils of backtesting, and building systematic strategies. Don’t forget to click the LIKE button on here. It gives you tons of bonus points.
That's it for today. Thanks for reading!
Don’t forget to do the quick survey. SURVEY LINK
Trade at your own risk. Be smart. Have fun. Call your mom.
DISCLAIMER: Nothing in “50 Trades in 50 Weeks” is investment advice. Do your own research and consult your personal financial advisor. I’m putting out free thoughts for people who want to learn. This is an educational Substack. Trade your own view!
If you are passionate about learning how to trade…
Subscribe to 50in50 for free right here.