Random Strategy Development Thoughts
This post will only be of interest to mechanical strategy developers/traders like myself (and even that is debatable). You’ve been warned.
Two random thoughts:
1. Abnormal Market Filter and when it’s appropriate
2. “Time Machine” Strategy
Abnormal Market Filter and When It’s Appropriate
I was asked this week to look at applying the abnormal market filter that I’ve been talking about recently (ex. here, here, and here) to an existing developer’s strategy.
What I found is that running a relatively sensitive filter (like I do with YK) completely broke the strategy. Instead I had to apply a much less sensitive filter (like I do with Scotty). This assignment helped me to flesh out my thinking a little bit more on the subject of which flavor of the filter is appropriate and when.
To understand what I mean, you have to peek under the hood of YK/Scotty just a bit:
At this moment in history (remember, it’s adaptive and always changing) YK is a contrarian strategy that is keying on whether the market is overbought/oversold. In contrast, Scotty is keying on the degree to which the market is OB/OS.
To illustrate, imagine a strategy that went long when the market fell below some moving average (this is analogous to YK), versus one that scaled into positions based on how far the market had fallen below that moving average (analogous to Scotty).
Adding a very sensitive abnormal market filter to YK makes sense because we’re letting the strategy do what it does best unless the market slides into the abyss. Adding that same sensitive filter to Scotty is counterproductive because we’re reducing position sizes just as the strategy is ratcheting up exposure.
Working with this developer and his strategy, I found he’s much more Scotty-like, than YK-like, hence the reason that a less sensitive filter was a much better choice.
This isn’t a critique of which approach is better or worse. They’re just two different approaches to the same problem.
“Time Machine” Strategy
I was inspired by Market Rewind’s post Ponzo’s Time Machine to develop something I’ll call (for lack of a better name) the “Time Machine” Strategy. I didn’t really expect the idea to work out, but it was an intellectual challenge, so what the heck.
Unlike MR’s post, which took a very long-term view of the market, I wanted to look at very short market slices. Here’s the concept:
Every day the strategy compares the previous X number of trading days (for example, I’ll use 10 days) to all other 10 day periods in the market’s history (up to that point in time) to find periods with a high Pearson coefficient to the current 10 days. It then looks at how the market reacted the day following those matching instances.
Because as I’ve written about many times, the markets are constantly evolving, I wanted the strategy to be “adaptive”, so I weighted each result by how recently it occurred (newer instances receiving a larger weighting). On each day I then used this weighted result to generate a prediction for the following trading day.
At the end of many, many hours of programming, tweaking, and then eventually, flat out brute force curve-fitting, I couldn’t make the concept fly. I’m sharing my pain here in hopes that I might spark an idea in another strategy developer.
That’s all for the random thoughts. Hope everyone is surviving these monstrous markets with hides intact.
Happy Trading,
ms
To stay up to date with what’s happening at the MarketSci Blog, we recommend subscribing to our RSS Feed or Email Feed.
Filed under: Trading Strategies | 7 Comments



I am reacting on your beautiful time machine backtest. It is close to pattern recognition.
I suspect that your experiment fails because linear correlation captured by Pearson is a very weak way to measure relationships between variables. It could happen that if a given pattern repeats, the day following return can be forecasted but the odds are high that the relationship is not linear.
I have run many experiments in this field with wavelet theory and pattern recognition methods. One basic idea that you could try and seems to work is flag each day with a letter:
H if it is up significantly, D if it is down significantly, O if nothing happens. Then given a set of letters for a week (5 letter), you analyse if you can predict the word for next week. Moreover you check if when you are advancing in next week, you can improve the forecastibility of the remaining days of the week with the knowledge of last week word + letters for first days of the week. You should find that it works surprisingly well.
Shivar
RE to Shivar: interesting approach you talk about (taking a more binary approach to daily returns rather than using actual daily returns). I’ll add it to the to-do list (but not anytime soon, my brain is fried on this particular subject right now =)
I’ll add one more issue with the Pearson coefficient approach – it doesn’t account for the volatility of each set of 10-day returns. Imagine one set of days where the market moves in some pattern with relatively small daily moves, and then another set that moves in that same pattern (in terms of each day relative to the others) but with big monster daily moves. That’s going to look very correlated statistically, but be very, very different in terms of what it says about the market.
Thanks for the thoughts,
michael
For the time-machine idea, you could try taking a weighted average of the returns, with the weights determined by the Pearson coefficient. Negative weights would have the sign reversed. It’s also easier to make it adaptive, because you can use all the returns for the past n periods. And you can calculate a variance of your estimate, which should give you some idea about what kind of confidence you should have in it.
To account for changes in volatility, you could use volatility adjusted returns. I’ve found that when using past returns to predict future returns that the results are better if you divide each days return by some measure of volatility (ATR, RMS change, mean absolute change, Bollinger Band width, etc). Then you multiply by the same measure to produce the actual prediction. Although the linear regression sort of does this automatically.
I also don’t think that a linear correlation is likely to be useful for determining which past periods are most like the current one. Price patterns never repeat exactly. It’s like trying to change your prediction based on whether RSI is at 90 or 91. You just won’t get that kind of precision in market patterns. In terms of information theory, I would guess that really good indicators can only give you maybe 2-3 bits of predictive information. And the best predictive methods you can come up with aren’t likely to provide more than maybe 4-5 bits of predictive information total. I would guess that a 10 day regression fit is probably about 12-18 bits of information (and possibly as many as 30 bits), which means you probably have at least three times as much noise as signal. Also, in order to actually have 15 bits of information you need at least 32,000 samples. On daily returns that comes out to about 128 years. On 1-minute bars it’s about 100 days. So what you are trying to do might work on an intraday basis if you assume the market hasn’t changed much in the past 2 years and you can process everything that fast. Alternatively, if you have about 300 years of daily data and assume that things haven’t changed it should work then too.
RE to jkw’s three comments:
1. RE weighting by Pearson coefficient: funny, that’s exactly what I did. I didn’t mention it in the post for the sake of brevity.
2. RE vol-adjusted returns: agreed. Perfectly good solution.
3. RE linear correlation not useful: I might agree, but not for the reason you mention. Obviously historical changes aren’t going to repeat exactly, but the point of using the correlation value was to try to gauge how closely they repeated. Not a defense of the approach – I think it’s weak for a number of other reasons – but I don’t think this is one of them.
P.S. I have no idea what this “bit” thing is you’re talking about =)
michael
Hi Michael,
I once implemented a little bit more complex version of what you call the „Time machine“ strategy. The comparer really found astonishingly similar patterns. It worked best if you had a “sliding window” of comparison, so not a fixed 10 days but a sliding time base weight.
As an additional step I made a “top list” of curves fitting the current situation and weighted them to a resulting projection to trade on. Unfortunately it just looks as if it would work, it had some problems with unexpected breaks in the market.
Regards
Oliver
I wrote up something quick about information theory on my nlog. Basically what I’m saying is that you need a very large sample size to have a 10-day linear regression matching system work. With just 10,000 samples (40 years daily) you’re mostly going to match something that isn’t actually very similar. The reason is that you can probably have on the order of 20,000-50,000 fundamentally different 10 day price patterns (you get 1024 if you just look at up/down for 10 days). Which means that when you only look at 10,000 past observations you can’t expect a good match. You certainly can’t expect enough good matches to infer anything. If you go down to 3-4 days, you might be able to actually do something (though I still don’t think this is likely to work well enough to justify the effort).
On the other hand, there probably are some patterns that occur frequently. While you can’t expect a good prediction every day, you might get a very good prediction every now and then. The trick would be to look for n-day patterns that match very well a significant number of times, and then match the first n-1 days against the recent past every close. You mostly won’t get matches, but when you do you will have a real prediction.
There may be more to it than just price, Michael… I understand many successful quants use the generalized method. All I’m saying is that it may be worth some “discreet inquiry”. You’re good at that, I believe?!