The Trend IS NOT Your Friend

trendiness-explainedThe trend is NOT your friend. The trend used to be your friend, but it isn’t anymore.

I read somewhere that the stock market had become more mean-reverting and less trending in recent years, and I wanted to see if I could put that to the test. Many of the books I’ve read have been about trend-following investing. So if the trend is dead (or dying), I’d certainly like to know about it.

But how to test “trendiness”?

I decided to code an oscillator in AmiBroker. It works like this:

Any time the index price has a set of three ascending or three descending closes in a row, that little ‘trendlet’ sequence is counted. Longer runs of ascending or descending trends are recorded as multiple trendlets, as they should be, since a longer trend should have more weight than a shorter trend.

As you can see in the lead image, the brackets denote sets of three ascending or descending trendlets. Note the overlaps, and also note that one price breaks the set (marked “X”) and so doesn’t count as a trendlet.

Now count the number of trendlets over a moving lookback window, and keep a running total. The fragment above, if looked through a moving window of 12 bars, would have 6 trendlets.

Then I smooth the curve with a moving average, as otherwise it can be very jagged. We can then get an immediate visual sense of how an index (or stock or commodity etc) has changed its trendiness over time. For the longterm trendiness of indexes, I chose a lookback of 120 and a moving average smoothification of 120.*

Look at the S&P 500 index since the 1920s. The index’s trendiness has been much higher in the past than it is now. In fact, it appears to be highest in the 1950’s through the 1970’s. Since then, the market has gotten less and less trendy.

SPX trendiness
S&P 500 index from the 1920’s to the present, showing the changes in trendiness over the years.

My conclusion: trading systems and methods that rely on trend following are less likely to work – at least for stocks – than they were 30-40 years ago. Whether the market is getting  more mean-reverting, or just getting more random, is not addressed by this oscillator. Perhaps for a future post I’ll take a look at that.

One thing I find interesting about the trendiness of the S&P 500 is that the early decades of the 1900s have a lower value that is similar to recent times. The market has gotten more trendy and then less trendy over the past 100 years. I wonder why?

One other observation: the oscillation in the indicator for the S&P seems pretty regular. Is there some sort of seasonal component to trendiness, and can one exploit this by deploying trend-following systems only when trendiness is at a peak?

Below I have some other indexes displayed with their trendiness oscillators. The sets of data are much smaller than the S&P, but there’s definitely an evolution in all of them, either with the average level or the amplitude of the swings. Also note the general trendiness levels of each market. Some markets are simply more trendy than others. You might need to click the image to view it better.

DAX trendiness
DAX index.
EuroSTOXX 50 trendiness
EuroSTOXX 50 index.
Mexico trendiness
Mexican Stock Market index.
Nikkei trendiness
Nikkei index.
Russia trendiness
Russian Stock Market index.

 

SC trendiness
Shanghai index.

* smoothification: noun. The act of smudging a perfectly good set of number because you don’t like all the embarrassing peaks and valleys.

Mexico in December (Seasonal Trading Patterns)

"Flag of Mexico" by Alex Covarrubias, 9 April 2006Based on the arms by Juan Gabino. - This vector image was created with Inkscape.Mexican Government. Licensed under Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Flag_of_Mexico.svg#/media/File:Flag_of_Mexico.svg
“Flag of Mexico” by Alex Covarrubias, 9 April 2006 Based on the arms by Juan Gabino. – This vector image was created with Inkscape.Mexican Government. Licensed under Public Domain via Wikimedia Commons – http://commons.wikimedia.org/wiki/File:Flag_of_Mexico.svg#/media/File:Flag_of_Mexico.svg

 

Fresh on the heels of my seasonal trading win with a Treasury Bond ETF (TLT), I thought I’d poke around with my own seasonal-trend research. Jay Kaeppel is in my mind the King of Seasonal Trends, and he’s even written a book on the subject. I thought I’d sniff around and see if I could come up with something too.

After browsing through the world index data I have, my thoughts settled on my nearest international neighbor: Mexico. Mexico’s economy is closely linked with the United States, but different factors drive it (commodity prices for example). So why not take a look?

I busted out AmiBroker and came up with a quick script that would allow me to enter and exit a trade based on the month of the year. After finding the best calendar month, I was able to fine tune the script so I could focus on particular days of the month for entry and exit.

The equity curve is compounded, starting with an account of $100,000. Since this was actual index data I was looking at, I needed a large position size otherwise it wouldn’t trade. I did include commissions, but they’re negligible for this test.

I first noticed that December was the best month of the year, followed by November. However November didn’t seem to have quite the success story as December. So with a little fine-tuning, I came up with the best seasonal plan:

• Buy on the 15th trading day of November.

• Sell on the first trading day of January.

It generates an exceedingly smooth and supple equity curve, as you see below.seasonal Mexico best

Compare that to the worst month of the year for the Mexican stock market, which is October:

 

 

seasonal Mexico worst

As you can see, the market had a devastating blow in October 1987 that the equity curve never recovered from. Even excluding that first year of data, it’s a pretty bumpy ride.

Check out these stats comparing “December Plus” vs October:

Screen Shot 2015-05-27 at 9.09.04 PM

Pretty sweet, yah?

Funnily enough, this is very much like the S&P 500 seasonal pattern. For the S&P the end of the year is usually best, especially December. Therefore a seasonal trading system based on the Mexican stock market might not give you the diversification you’re looking for (unless oil prices are up).

You can’t trade the index directly of course, but those smart folks over at the ETF factory have cobbled together something you can spend your money on. Several somethings in fact.

There’s EWW for starters, or UMX if you like a little more sizzle in your ETF steak. And if you’re feeling bearish, there’s the inverse and leveraged SMK. The last two seem a little slim in the volume department, so do your own research.

¡La negociación de valores puede ser riesgoso!

 

The Advice of Others

TLT-options-tradeFor those of you who are familiar with the iShares 20+ Year Treasury Bond ETF (TLT), you’re probably looking at that chart and thinking: “no friggin’ way did TLT jump 24% in a day.” And you’d be right. But none the less, I made 24%+ after commissions on a TLT trade that I exited this afternoon.

The secret behind this of course: options. And the reason I took this trade in the first place is because of a seasonal trend in bonds that often happens around the same time of every month.

There are a lot of finance blogs out there, and many bad ones (including this one? 🙂 ). There are a few people I really respect though, and one of them is Jay Kaeppel. His ‘hobby’ is discovering seasonal trends in the markets, and I’ve read his book on the subject, and enjoy his blog posts about seasonal and recurring patterns in trading. One pattern that sounded very interesting was a bump in bond prices at the end of many months (you can read about it here).

But how to play it? I’m not going to invest directly in bond futures, and in fact my brokerage doesn’t offer that. I can however buy an ETF that tracks bond futures. But TLT is a pretty low-volatility ETF. It actually has too little volatility to justify a swing trade with the position size I was envisioning. Even a winning trade might generate a loss after commissions. I could however trade options on stocks and ETFs with my brokerage. This allowed me to bring more risk/reward to the transaction. So that’s what I did.

I wanted to risk about $200 or so in hopes of making the same amount or more. I’ve learned (from Jay’s site and books I’ve read) that a good way to trade stock options on the long side is this:

• Pick an expiration date that is at least a month beyond what you think your exit date will be. This reduces the amount you lose in time premium as the expiration date gets closer.

• Pick a strike price that is firmly “in the money”. TLT opened on Friday around $120, so I bought a call with a strike price of $118. Ideally, I’d pick an option with a strike price that was close to where I’d place my stop loss. Sometimes that’s not practical.

Options with these attributes have a higher delta, and will track the underlying stock/etf price more accurately than would an out of the money option, or one with a nearer expiration date. If the price were to move the wrong way, the option will still have plenty of value and it will be easy to offload at a respectable price. No one wants an out-of-the-money option that expires in five days!

The downside is that these long-expiration, in-the-money options are more expensive. A single contract was priced at $410, and I bought two of them. If I lost $100 per contract, that was my sign to get out.

With options, the upside can be big, but so can the downside. If TLT had lost 2%, I would have lost several hundred dollars. Just because you need less money to enter a position does NOT mean you can ignore your downside risk. I’ve entered into some option trades being fully prepared to lose the entire thing. You must keep your position sizes polite and demure.

Fortunately, this trade went the other way, and I made $103 x 2 before commissions. Nice!

Now if you’ve actually read Jay’s post, you’ll see it says to hold for more than two days. I got out early, and I have no regrets. I made the money I’d hoped, and I have a sneaking suspicion that today’s bump won’t last. So I’ll take my profits while I can.

Bonus: this makes up for (and then some) the bad trade I had in gold, which stopped out this morning. Win some, lose some, and hopefully win more than ya lose!

Do Good Days Follow Good Days?

one-day-to-another

Have you ever wondered whether one good day tends to follow another? I have, and I’ve done a little research.

I’m sure many times you’ve looked at a chart, or seen a list of the day’s top stock winners, and wondered “what if I bought this tomorrow? Would it go up, or would it go down?”

There are of course two opposing logical predictions you could make when you see a nice juicy green bar on today’s chart:

1. “Buyers are excited about this stock. It must be a good one, so it’ll keep going up tomorrow as well. I should buy at the opening bell.” This is a momentum strategy.

2. “Short-sellers will see this as an opportunity when the stock declines back toward its original level. And those who already own it will want to take profits while they can. So I should avoid going long in this stock, as it will likely snap back tomorrow.” This is a mean-reversion strategy.

Neither is wrong. Either one of these can happen, depending on many circumstances. But what’s the probability of one good day leading to another?

Let’s get our hands dirty with some data. But first, some parameters:

• I looked at all the stocks currently in the Russell 3000 index, from Jan 1, 2012 through May 18, 2015. The closing price at the time must have been greater than $2, and the 10-day average volume was greater than 50,000 shares/day. This gave me lots of data but avoided really illiquid stocks.

• I then defined my ‘signal’ day as being any day with a close that was 3% or more above the open. This is not the same as comparing two days’ worth of closing prices. You’re welcome to compare your own data on a close-to-close basis if you’d like!

• For each signal (and there were many thousands of them), I then looked at whether the close of the following day was less than its open. After all, the point is to decide whether we should pile in on the following day. Comparing consecutive closes is problematic from a trading standpoint, as it requires the intraday scanning of many tickers.

So basically, when we get a nice green bar on one day, do we get a nice green bar the following day? Or do we get a down day instead? Also, does the probability get better or worse depending on the size of the ‘signal’ bar? Below I’ve graphed the probability of failure, based on the size of the signal bar.

Screen Shot 2015-05-19 at 9.32.25 AM

Well it’s not good news. Taking no other conditions into consideration, you have a greater than 50% chance of having a loser day after a signal day. And the chances of having a down day (open to close) only increases, as the size of your signal bar increases.

But might there be any conditions that would make a stock more likely to ‘go green’ on that second day? So I decided to see if history tends to repeat itself. I then looked at the same data set, but filtered for stocks that had at least one instance of two days in a row where the close was above the open by 3% (within the last 60 bars).

 

Screen Shot 2015-05-19 at 9.30.29 AM

First, let me apologize about the scaling. It’s difficult to force two google charts to have the same scaling. But if you look carefully, you can see that the probabilities are pretty similar…until you get to the >16% range. For some reason the failure probability shoots up dramatically when you’ve already had a two-good-day sequence in the past. No idea why that might be.

A question comes o mind: do the number of signals in the past 60 bars make a difference? If a stock is prone to good behavior, will it affect the probability? To find out, I then sorted by the number of these previous two-day ‘bumps’ that occurred in the previous 60 bars. These signals could overlap: three days of 3% would count as two signals. On the chart below I’ve called these signals “bumps”. And this is what I got:

Screen Shot 2015-05-19 at 9.44.07 AM

 

For the first time, the probability of failure has dipped down below 50% in some cases. Specifically, a stock that has generated 5, 6 or 8 signals in the previous 60 bars is slightly more likely to have an up day after we get a signal.

Yes, I see it too. WTF is going on with the 7-bump set of data? No idea whatsoever. There were over 1000 samples in the 7-bump set, so it’s not due to some outlier phenomenon. Even the 8-bump set had >500 samples. Above that, the data gets patchy so I would ignore the last bar.

So what does this mean? I think it ties in well with my earlier research, in that the recent history of a stock’s performance can be an indicator of future behavior. When designing a trading system, you might consider this aspect for filtering the most likely candidates to trade.

Shorting the VIX

svxy-trade

Today I completed a trade using the ProShares Short VIX Short-Term Futures ETF, (ticker: SVXY). I entered at the close on 5/6/15 at $77.73 per share, And exited at the close today (05/14/15) at $83.64. That’s a profit of 7.6% before commissions, for six days of trading. Not bad!

It’s going to hurt my head to try and explain what the heck this thing is. But I’ll try anyway, and wince a little as I do. Someone correct me if I’ve screwed up.

“VIX” is the CBOE’s index of the implied short-term volatility of S&P500 futures. It’s an index that doesn’t track prices of stocks, but instead tracks the expectations of how crazy things are going to get. If the market thinks it’s in for a wild ride, volatility increases, and the VIX index goes up. Usually increased volatility is due to downward expectations in price, so the index is often called the ‘fear index’. You can read more about it here on the CBOE’s site.

Someone, or several someones, had the bright idea to create an ETF based around the VIX, so we can trade on volatility instead of price. The problem with VIX-based ETFs are two-fold though:

• They have a downward bias. I’m sure this has to do with futures expiration rollovers or contango or some other dance step…not my area of expertise. But over the long haul, they tend to drift downward. This makes any long plays harder because of the bias in the wrong direction.

• Mean-reversion systems often rely on a downward spike or significant event to act as a signal, and the return is made on the drift back to the mean. But the VIX tends to spike upward. Some bad news event triggers an increase of volatility, the VIX spikes upward, and then slowly drifts downward again. Volatility just doesn’t seem to spike downward in the same fashion.

Some other even more brilliant people decided it might be fun to have a short VIX-based ETF. This flips those two problems on their heads, turning them into features. A short-VIX ETF has both an upward bias, and spikes downward before reverting in an upward direction (usually).

I can trade that!

Below you can see two charts for the most recent time period. Note how the short-terms ups and downs are pretty similar between SVXY and SPY, but the longer term moves are different. For example the SVXY has been climbing pretty steadily over the past few months, while the SPY (S&P500 ETF) has been trading in a range. That means more opportunities for trades.

svxy-vs-spy

Unlike the VIX, which is direction-neutral in the long term, these ETFs have direction. So you really need to test with the ETF rather than the underlying VIX index. But the SVXY has only been trading since October 2011, which doesn’t provide quite the data I’d like for backtesting and developing systems.

Another thing to keep in mind: SVXY has a much greater daily percentage change than SPY. So adjust your positions accordingly, otherwise you might lose the farm. Today for example, SPY gained 1.04% from the previous day, while SVXY gained 2.04%. That’s almost twice the increase. On October 13th, 2014, SPY dropped -1.64%, while SVXY dropped -9.78%! Plan accordingly.

That said, I did come up with a nice little system that tests well. It tested so well in fact, that only one trade out of about 30 was a loser. Do I trust it? No, not completely. I don’t know how it’s going to behave during major market turmoil. But it looked sufficiently good that I was willing to put a little money on it. And the first trade was a great success.

I’m not prepared to discuss the system at the moment, but that’s not the point of this post. I love the proliferation of ETFs that has occurred over the past few years. There are many ways to make long-only trades that used to be impossible. Now if someone would come up with a triple-leveraged short corn futures ETF!