Overbought Territory?

I have a diffusion indicator I use, and it’s telling me we’re probably near the peak of the current short-term rally. Is it predictive? Sometimes. Except when it’s not.


Screen Shot 2015-04-24 at 8.33.22 PM
Click to enlarge.


This is calculated by recording the diffusion ratio of all the stocks in the Russell 3000 index that are up 20% or more in 20 days, vs those that are down 20% or more in 20 days. [ up ÷ (up+down) ] I then calculate a short-term momentum function to generate the curve you see in blue. Overlaid with this in red is the SPY ETF price, a proxy for the S&P 500. Note that when the blue line dips below .75, everything seems to go pear-shaped in the days following.

Add to the fact that some of the indexes have hit all-time highs today, and, well…

Time to hang up the short-term momentum trades and prepare for the short-term mean-reversion trades instead!

No mo' momentum, yes mean reversion!
No mo’ momentum, yes mean reversion!

Staying the Course (Even When It Hurts)

It’s interesting that there are quite a few trading blogs out there devoted at least in part to the psychology of trading. Who knew we were all such nut-jobs? I was reading one today and it got me thinking about my mental track record so far.

First off, I’d like to give myself a pat on the back for sticking with the system the vast majority of the time. No matter what the trading system, I’ve done a pretty good job of staying with it and following the rules to the letter. My disciplinary success rate is definitely not 100%, but I feel pretty good about it. And I do suck at some stuff too, which I’ll save for later in the post.

Take for example an ill-fated trade with Weight Watchers International (WTW). A friend of mine had described a swing-trade system that took advantage of mean reversion to catch a bounce. Sometimes it turns into catching a falling knife. Which is what happened on this particular trade.

staying-the-course-(WTW)For this particular trading system, more often than not, the stock rebounds. It rebounds over 60% of the time in out-of-sample backtesting, and the forward-testing looked good too. But there are those other 40% of trades, and sometimes there’s a doozy. This one never turned around while I was in the trade, and finally stopped out with a >12% loss. Ouch!

It’s one thing to look at a chart from the past, and quite another to experience each red bar as it happens. Every day at the closing bell I would look at WTW and say “Really??! Aw c’mon already, turn the other direction!” And of course it did that the day I after I stopped out, at least for a short time.

Every day there was a temptation to get out. But I stuck with it, because I knew that if I quit before the rules said I should, I would invalidate the whole trade. It would then become not a statistic to apply to my overall system health, but some random trade I made for no reason.

The times I abandon a trade is when I don’t have confidence in the underlying system. There have been several times where I’ve either learned something new, or realized I’d made an error in my testing, and invalidated a system I had been trading. Or worse, I was trading a system based on discretionary reasons (i.e. “gut feelings”). Then I start to second-guess everything.

I can stick with a trade very well if I’ve got hard numbers to back it up. But if I doubt those numbers, or didn’t have the hard evidence in the first place, then I’m a wibbling bowl full of nervous jelly.

Some mental techniques I’ve learned along the way so far:

– If you’re trading on an end-of-day basis, don’t constantly watch the market. It will only cause you heartache. There are only two emotions you can realistically feel while a trade is open: mild anxiety or wild panic. So what’s the point in peeking? (I must admit I’m only partially successful at this part.)

– Trust your research. If you’ve properly tested your system with out-of-sample data, then it should continue to work a given percentage of a time. If over time the percentages of wins drops off, it’s time to pause the system until paper-trading shows good results again. But no single trade is going to tell you whether a system is broken (or working).

– Don’t bet the farm. You’ve heard that one before, I know, but it’s true. Losing $1000 hurts more than you imagine it will. Ask yourself “what amount could I stand to lose three times in a row and still continue trading?” Err on the side of small. Heck if your trade goes from a profit to a loss because your position size was small compared to commissions, it’s still a win. Because it’s a) a small loss instead of a big one and b) counts as a win in your live forward-testing. Get rich slowly, instead of getting poor quickly.

– When you exit a trade, don’t look back. Don’t look at what the price did the day after, or even a week after. MAYBE take a look a month or two later, but really, what good will it do? Doesn’t change a thing. If you stuck to your system, then all you can say is “well that one didn’t work out.” And if you didn’t stick with your system, then you’ll just be reminded how foolish you were.

So what do I suck at? Well I hinted at it above. I’m often too quick to try a new system with real money, when perhaps I should let it stew for awhile with paper trading before jumping in. I like inventing things and trying them out, so it’s difficult for me to NOT trade a new and promising system. Fortunately I’ve had enough sense to keep my positions small, so as not to get hosed.

What are some mental tricks/techniques you use to combat the wibbling-jelly feelings that trading the markets can sometimes cause? Leave them in the comments section!


Using Market Advance/Decline Divergence to Predict Short-Term Direction

For a few months now I’ve been tracking my own market breadth/diffusion index by hand in a spreadsheet. I realized a few days ago that I could automate it and also create historical composite data by using certain commands in AmiBroker. Since then I’ve been ruining my eyesight gazing at charts and spreadsheets, and I’ve come up with something that looks interesting.

Here’s a chart to prove I’ve been working hard:

Screen Shot 2015-04-14 at 3.11.28 PM

Here’s what I do:

For the set of Russell 3000 stocks, each day I have AmiBroker count up the number of tickers that closed at least 4% above their closing price from yesterday, as well as the stocks that closed at least 4% down. Then I calculate the ratio of advancers to advancers+decliners. Ratio=A / (A + D). That’s the column on the far right of the spreadsheet above.

I then look for divergences between this ratio and the closing price of the S&P 500. Most of the time it’s in sync, but every once in awhile it diverges. The S&P will go down while the ratio goes up, and vice versa.

Screen Shot 2015-04-14 at 2.54.35 PMThe upward red lines show potential bullish divergence, where the S&P went down and the ratio went up. The downward red lines show the opposite. The blue line is the closing price of SPY between 9/2/2014 and 4/13/15.

Ok so yes there’s a divergence from time to time, but does it hold any predictive value?

Very possibly!

60.00% of the divergence signals are followed by an up day for the S&P. Hmm, that could be useful, right? Now keep in mind I’ve only done this for the period in question, so it’s just a preliminary dip of the toe in the statistical water.

And I’m sure you’re asking yourself: is this actually better than pure chance? What if the market had “up” days 60% of the time? I’d better measure that as well.

Turns out during this period of time, the S&P closes up from the previous day 51.30% of the time. So 60% vs 51% seems pretty significant (pending further testing).

The reverse wasn’t true however. The negative divergence signal was predictive only 47.62% of the time. Perhaps the predictive power is dependent on the longer-term trend.

Screen Shot 2015-04-14 at 2.55.55 PMI don’t know if this measurement would be strong enough to trade SPY on its own, but perhaps it offers some short-term market-timing abilities when used in conjunction with other techniques. For those of you who like to crunch numbers, it’s something to explore.

Panicky Robots vs. the FOMC

robotsTrading Robots live and walk among us, and I have proof! It’s a conspiracy.

Today the FOMC (aka ‘The Fed’) stated “Several participants judged that the economic data and outlook were likely to warrant beginning normalization at the June meeting.” I.e. some of them wanted to raise interest rates. But that the overall consensus was to wait until later in the year or beyond to start raising rates.

Meanwhile, in an underground lair deep below Manhattan, a robot spotted the terms “FOMC” and “June rate hike” in a news feed, and red lights immediately started flashing. “SELL SELL SELL” flashed the words across the glowing CRT screen. The overhead lights switched to red warning lights, and the alarms rang out.

A lone human minder was startled out of his slumber, and leaped into action. After quickly reading the FOMC minutes he shouted “Aw, crap! It’s happened again! Stupid robots and their inability to gauge context!”

He hits the giant UNDO button and the SELL SELL SELL orders change to BUY BUY BUY orders. Within minutes, the spike downward is reversed, almost like it never happened. Then the human minder goes back to sleep, his job done until perhaps Elon Musk cracks another ill-timed joke about Tesla on Twitter.

And maybe by tomorrow if you search for it, you won’t find any evidence of the error. Because of course the robots will fix that. But you and I know. We saw it happen. And with my tinfoil helmet, I’ll keep the robots from erasing my memory of the event…

Swing Trade System for a Financial Sector ETF

FAS Double Down

I was intrigued by this ‘rough draft’ of a swing trade system that Oddmund Grotte had mentioned on his website quantifiedstrategies.com (post link here, and check the comments for more good ideas too). It was designed to trade XLP, which is an exchange-traded fund that tracks the consumer staples sector. A quick view of the chart seemed to confirm there was profit to be had, so I set about designing a system and backtesting it in AmiBroker.

It didn’t go so well however! Variations on the theme weren’t yielding positive results. I took a look at the losing trades, of which there were many…I noticed that there were quite a few winning trades that turned to losing trades after commission was deducted. Once again, the position-size / commission size ratio rears its ugly head. A winning system can be rendered a gibbering, quivering disaster with the addition of commissions that suck away the tiny wins.

So what I needed was more bang for the buck. If I could increase my average win per trade, I could potentially create a winning system. My first thought was to use leverage. But not real leverage, just a leveraged version of the XLP ETF. I was unable to find a leveraged version of the consumer-staples sector ETF. What, no one wants to day-trade the consumer staples sector for fun and profit? WTF?

So I headed over to the financial sector, where there are 2X and 3X leverages ETFs in both directions. I settled on the Direxion Russell 1000 Financials Bullish 3X ETF, a.k.a. FAS.

My goals were to develop a system that:

– can be profitable with a $1500 position size and a commission of $4.95 each for entry and exit.

– trades roughly twice per month on average.

– has a high win rate. Minimum 60% but preferrably >70%.

– The system would only trade one position at a time, but has a hypothetical $30,000 account to absorb mild drawdowns.

– is a swing-trade system, so the holding period is relatively short, reducing risk and increasing gains due to compounding. Note that my results here do NOT include compounding. Position size has a maximum of $1500 but is usually less because whole shares must be purchased, not fractions of shares.

This ETF started trading at the end of 2008 (wow, that must have been painful). So I set my in-sample period to be 1/1/2009 to 12/31/2012. My out-of-sample period is from 1/1/13 to 04/05/15. I did a walk-forward test for the holding period and profit target, and then selected the values that appeared most often (the “mode” of the results). If you don’t like my methodology, do it yourself! 🙂

Here are the rules I came up with for my “FAS Double Down System”:

1. The closing price of the signal day must be at or below the previous day’s close.

2. Set a limit-on-open order for the next day’s open that is equal to the closing price divided by 1.002. If you can’t trade using a limit-on-open order, you could set a limit order and then delete it if the order didn’t execute at the opening bell.

3. Sell if the close exceeds either 3.5% above the trade price, 20% below the trade price, or 24 trading days have transpired since the entry (with the entry day being day 0). All trades are done at close, not intra-day. Yes the stop-loss percentage is much bigger than the profit target, but this is common with a trading system with a high percentage of wins.

The results:

– This system yielded about 20 trades a year, which meets my roughly-twice-a-month goal.

– The hit rate – AFTER deducting $4.95 for commission on both entry and exit – is over 86% on average.

– About half of the 122 trades are just held for two days or so. The maximum duration aspect is basically for when the entry turns out to be faulty, and then you hold your breath, hoping the price eventually moves in your favor. Only five trades out of 122 hit the maximum holding period.

– the system has a CAR/MaxDD ratio of 0.58. There were values that could have increased that immensely, but it brought the number of trades down into the single digits per year, which is not what I was after.Also, there were some big losses right at the beginning of the ETF’s existence which are no doubt impacting the final score.

A higher position size would probably allow for a smaller profit target and possibly more frequent trading, and thus an improved CAR/MaxDD ratio. But I don’t have the bigger position size handy at the moment.

– The Average Profit/Loss per trade is 2.63%,  and the Average Bars Held was 7.13.

– Wins: the largest win was $708.52, and the maximum consecutive wins was 22. Not a typo. Twenty two.

– Losses: the largest loss was -$586.57 and the maximum consecutive losses was 2. Not a typo. Two.

– This is a system that makes a bunch of smaller wins and then every once in awhile takes a bigger loss. The stop only helps so much, because usually there’s some apocalyptic event that can’t be “stopped”…only recovered from somewhat with a longer duration. The average profit is 6.50%, but the average loss -21.54%. Did I mention it has a high hit ratio? 🙂 Three of the four most massive losses were at the beginning of 2009, so perhaps that makes you feel better?

Here’s the equity curve over time, rather than on a per-trade basis as you saw at the beginning:

FAS Double Down equity chartThe system makes a lot of its money during the rally of 2009. But there’s a fair amount of more modest profit happening throughout. That made me want to see if that hit rate was skewed in some way chronologically. I’d hate to find out I was getting 100% hits in 2009, and 50% hits in 2014. Well that turns out not to be a concern. Here is the hit rate, broken down per year:

2009: 79%
2010: 81%
2011: 86%
2012: 90%
2013: 93%
2014: 92%

Well hey, I can live with that! The profit seems to have flattened out a little over the last few years, but it’s still steadily heading upward.

One other downside to this trading system: about half the days each month are “signal” days, because of course there are a lot of down days each month. It’s the limit-on-open order that differentiates the winners (usually). Kind of annoying if you have to set a limit order so frequently that only gets filled one or two times per month. I suppose you could set an alert and jump in within a few minutes of the opening bell, but then you’re going to get some slippage as a result.

Would I trade this? Meh. I don’t know. The frequent false alarms would be kind of annoying. It would almost make sense to set aside some cash solely to trade this system, and just sit and wait patiently.

Also, because this ETF can’t be tested back before late 2008, there is no real stress-test of a bear market. Likely this system would require an overall market-health test to be complete. But hey if the market is in collapse or the system is generating too many losing trades in a row, shut it down until it starts working again.

As always, a system that looks good in backtesting, even using in and out-of-sample data, does not guarantee future results. Disclaimers are lame. But necessary.