Swing Trading System using Bollinger Bands

bollinger-band-tk-profit-old
The black arrow is the signal day, and the green arrow is the trade day (at open).

 

As promised, here is the system I was using that initially got me into the EXAM (ExamWorks) trade, making me over 10% in about 30 trading days, after commissions. But before I go any further…

DON’T USE THIS SYSTEM.

Why? Because the stop loss and profit target values are highly suspect. In fact, I modified these after I initially made the trade, because they were unreasonable. I’ll explain that a little further down.

I’ve always been fascinated with Bollinger Bands. It’s amazing how the price bars just flow between them, bouncing back and forth and never quite escaping. This of course is all backwards, because the bands are there BECAUSE of the price bars, not the other way around. Cause and effect is an important thing to keep straight when trading stocks.

That said, there are some recurring patterns that intrigue me. I’ve noticed that after the lows have hugged the lower Bollinger Band for awhile, they usually head in the other direction. Then, if all goes well, they smack up against the high Bollinger Band for awhile, like helium balloons on the ceiling at New Years Eve. Rinse, and repeat.

The system I came up with that got me into the EXAM trade was this:

• All trades occur at the open of the following day after the signal. This allows me to actually work for a living and then make my trading decisions after the market is closed, and put my orders in overnight for the opening bell.

• Market must be in an uptrend, as determined by the S&P 500 (SPY) having its 65-day moving average be above its 195-day moving average. No point in trying this in a bear market. *

• Close price must be above $15 and average 10-day volume must be above 100,000.

• I used a Bollinger Band of 20 periods and 2 standard deviations, based on the closing price. (I’ve since changed that…)

• My screening software looks for four bars that have their lows below the lower Bollinger Band, followed by a fifth (most recent) bar with a low above the Bollinger Band. The last low below the Bollinger Band must be less than the first low below the Bollinger Band. Just to be clear, if the signal day is day 5, then day 4’s low must be below day 1’s low. This little plummet can have other bars before it with lows below the band, but it’s the four below and then one above scenario that we’re looking for. Check the lead graphic as an example. NOTE: I’ve since tested and found that four bars below works better. But I didn’t use that for this trade, so you’ll only see three bars.

• Buy at the open of the day that follows the signal day (the bar with the low above the band).

• Now here’s where it gets particularly dicey. Set a stop loss at 15% and a take-profit amount at 21% above what you paid for it (the “tradeprice”). In other words, if the price closes either below .85*tradeprice or above 1.21*tradeprice, then sell that puppy the following day at open.

When I did all my backtesting with ProRealTime, I could only test a single stock at a time. So I would enter all the data into a spreadsheet and add up the totals. I would compare various variations to each other, and pick the one that made the most money. From a sheer time/fatigue standpoint, I could really only do this for 30-40 stocks at a time. PRT doesn’t allow you to test on a portfolio-wide basis over a whole universe of stocks.

So the reason this is dicey is not because it won’t make money…it tested pretty well in that regard. The problem is the drawdown! The other problem is the amount of time your stock might just be sitting around, drifting one way or the other, taking forever to hit either the stop or the profit target.

I picked 15% as a stop loss because I’d read somewhere that 15% was a good number. I’ve also heard lots of other numbers since then. The problem with a fixed percentage either as a stop loss or a profit target is that some stocks aren’t volatile enough to get to either point very quickly. Which really misses the point of a swing trade.

I’ve since run this scenario through AmiBroker, which allows me to test across a big batch of thousands of stocks. When I tested with data from 1/1/2000 to 12/27/2014, I got a profit gain of 169.41%, bringing a hypothetical investment of $30,000 to $80,821.94. That was reasonably decent compared to some other systems I’ve worked up. The problem, as mentioned before, is the drawdown.

1. Portfolio Equity

Look at those big dips as the market fell apart in 2002 and 2007-2008. Interestingly, this system is kind of flat in 2014, even though the market has been on a upward tear. The sign of things to come?

Note also the straight lines at the end of 2002 and between 2008-2009. This is where the filter for the S&P 500 kicked in, keeping me from trading in a bear market. Otherwise losses would have been much larger.

2. Underwater EquityThis hypothetical portfolio traded a maximum of 5 positions at a time. Look at those painful drawdowns in 2003 and 2008…a maximum 24% of the entire portfolio! Hurts my eyes to look at.

So how to fix this? One way would be to use stop loss and profit targets that are tailored to the innate volatility of a particular stock. One way is to use Average True Range as a basis for stops and targets. This tailors the exits to what the stock has the potential for, rather than some one-size-fits-all percentage. I’ll talk about that in a future post.

By the way, most of the portfolio-related stuff I’ve learned from Llewelyn James, either through his book or directly from him. Including the reasons for why 15% is a dumb number to blindly pick. This particular swing system (DON’T USE IT!) is all my creation though.

Disclaimer: I think I mentioned enough times that you shouldn’t use this system. Not just because trading in general is risky, but because this system isn’t particularly good. If you’re into CAR/MDD** ratios, it has an embarrassingly low value of 0.17 It is however the basis for other ideas that appear to work better. Oh and I should mention that once I realized a 15/21% stop/profit was f-ing cray-cray, I changed it to a 3 x ATR/4 x ATR stop/profit instead…which got me 10% profit.

Now I’m going to go sit and watch my leveraged short-oil ETF as it goes through the roof. 🙂 Oil dipped below $50 today, and I’m cheering for it to go lower.

-Matt

* BTW I’ve since started using a 40-day vs 120-day comparison for bear markets…a little faster to respond to a downturn, but also will likely create a little more choppiness and false starts at the end of a downturn.

** Compounded annual return divided by the maximum drawdown. This rewards profit but also penalizes drawdown. Keeps your account from hemorrhaging money while you’re waiting for the next big win.

Backtesting with AmiBroker vs ProRealTime

PRTvsAB

So I finally bit the bullet and bought AmiBroker, which is comprehensive stand-alone software for charting and – more importantly for me -backtesting technical buy/sell systems.

Up until now I’ve been using ProRealTime.com‘s free Java-based charting software. The end-of-day data version is free, but their realtime intraday version is subscription based. It’s really nice considering the price, and allows you to program stock screeners and do limited backtesting using a BASIC-like scripting language. Other than being a little buggy sometimes, it’s a pleasure to use.

The major drawback to it is that you can’t backtest your trading systems across an entire universe of ticker symbols. You can only do one ticker at a time. So to get a decent overview of your system, you have to individually test each stock, record the results in a spreadsheet, and then add or average things up to get a sense of how one system might compare to another. But even testing 30-40 stocks can be quite laborious, especially if you’re also tweaking parameters in your system.

Enter AmiBroker. While there are web/cloud-based backtesting platforms available, those are mostly subscription-based. AmiBroker is the only software I know of that is standalone, will test a large batch of stocks at once, and costs a one-time fee. It’s not cheap ($279 at this writing) but I finally decided it was worth the ‘investment’.

I’m a Mac guy, so the fact that it’s PC-only is a drag. I had contemplated running it on a Windows virtual machine on my Mac, but fortunately my kids got a new Windows laptop for Christmas, and I’ve inherited their old one. So I’ve installed AmiBroker and am slowly getting the hang of it. It’s complicated, but having already learned ProRealTime, I’ve got a head start. Note the two platforms are unrelated except that they’re both charting software.

Tonight I was able to translate one of my systems from ProRealTime into AmiBroker’s scripting language, and for the first time ever was able to run a test over a large group of stocks (thousands) and over an extended period of time (Jan 1 2000 to the present). I picked my most winning-est system to test. And the results?

Kinda pathetic.

Why does the system look so good when picking supposedly random stocks on ProRealTime, but look so bad when using AmiBroker? No friggin’ idea. A little depressing, but I guess there’s room for improvement before I invest more money with that particular system.

P.S. The way the two platforms are configured, I will probably continue to use both of them. I’ll use PRT for checking my latest trade data and possibly screening, and AmiBroker for the actual backtesting. We’ll see if that changes going forward.

UPDATE 01/07/15: One thing I’ve found is that the free downloadable EOD data from yahoo finance has a few errors in it. Every once in awhile I lose my shirt or become an instant paper-millionaire due to glitches in the data. I’ve gotten into the habit of a) checking the best and worst trades of a backtest to make sure they don’t look suspicious, and b) not refreshing my data very often.

Wait, what? Not refresh the data?! Yes, really. If I’m testing 15 years of data, does it matter if my end date is 12/27/14 vs 01/07/15? No I don’t think so. And I’m not currently using AmiBroker as screener, so fresh data is not worth the hassle of cleaning it.

Also, AmiBroker allows your backtests to look into the future, which is a bad thing. And it’s quite easy to do it in a subtle way too, like for example accidentally using the Close price as a signal while buying on the Open price of the same day. So it’s important after designing a backtest system that you check to make sure the buy and sell prices are exactly what you expected them to be, and occur on the days your system indicates precisely. While there is a function to test for crystal-ball-reading, it’s not automatic.

EXAM sold at >10% profit (swing trade)

Screen Shot 2014-12-26 at 1.05.45 PM
“Days in market” is a rough calculation of trading days, based on the difference of the calendar trade dates multiplied by 5/7. So it’s approximate.

 

So this morning I sold ExamWorks Group Inc (EXAM) for a 10.71% profit after deducting commissions. This was using a swing-trade system I came up with using Bollinger Bands. I’ve since deprecated the system because I have other ones that seem to backtest a little better. The limited amount of forward-testing I’ve done with this system has yielded three wins, four losses, and three “paper trades” still in play. Unlike the paper trading however, I back up my technically-based stock picks with fundamental research. Just because a stock gives me a signal doesn’t mean I’m going to pick a likely loser.

One “problem” I’ve run into is that since I started trading with my eyes open (so to speak) back in October, I’ve sold four stocks, all at a profit. I have yet to have anything stop out at a loss! Am I a naturally-gifted trader with amazing innate talent? No of course not. It’s just a good time to be trading at the moment, and I’ve been mostly lucky, and very careful.

So I predict that EXAM will go higher, since they were recently added to the S&P Small Cap 600 and seem generally be strong. But what do I know? Anyway, my rules say “sell” so I sold, and I would be foolish to convert a swing trade into a long-term trade.

I’ll discuss my Bollinger Band swing-trade technique in a future post, and also why I don’t think it’s a good plan anymore.

Disclaimer: I don’t know what I’m talking about. Don’t follow my advice.

 

The Single Most Important Book (So Far)

As you may have read in my “Me, Me, Me” page, I got started as an active trader by reading this book. And while it’s an amusing and interesting story, the ATA (Actual Trading Advice) is pretty slim. So it was something of a fluffy, puffy book for me.

Not satisfied, I went looking further. I was heading to Hawaii for a vacation – no, NOT earned with all my stock market winnings. I wanted some ebooks for the plane etc, and found a positive gem.

It’s called The Honest Guide to Stock Trading, by Llewelyn James. I got lucky with a really great book at the beginning of my journey, because there are some real dogs out there. Llewelyn does a really great job of explaining not just how to trade, but loss management, portfolio management, position-sizing etc. It’s like a shot of tequila…distilled down to its raw, unfiltered state.

I also like that he insists on testing everything. I’m a huge skeptic when I come across technical traders who read charts like tea leaves and horoscopes. “This one looks like a cup-and-saucer. This one looks like a double-bottom. This one looks like a girlfriend I had back in February of last year…” But not Llewelyn. He gets his robot-ninja chart-crunching software out and smacks the heck out of those charts, until money drips out.

But he’s very clear: the money drips and sometimes runs dry. It doesn’t pour out like some charlatans claim. In short, he speaks to my “prove it to me” nature.

Without hesitation I recommend his book. His other one is good too, but start here. Oh and he has a blog too (here).

Stock Trading “System” Scams

Screen Shot 2014-12-21 at 1.54.35 PM

As I was doing some deep research last night, I was reminded that everyone is out to make a buck/euro/yen. Nothing wrong with that. But there are a lot of trading scams aimed at the unwary. There are some honest-but-high-priced “systems” out there too, with claims ranging from unlikely to outlandish.

As a professional photographer by day, I’m all too familiar with people trying to sell me a system guaranteed to make me more money. One thing I learned early on though is to ask yourself a simple question: if these people are making tons of money with their systems, why are they wasting their time selling them to other people?

I think the exception might be the few – very few – people who are genuinely trying to help others learn trade more successfully. The same is true for authors who write about trading the markets. Ask yourself, why’d they write this book? Authors don’t usually make a lot of money, at least compared to successful traders.

If I had a brilliant system to make millions in the stock market, I’d either be too busy to sell it to others, or sunning myself on an island somewhere (thus still too busy to sell it to someone else). And if I did decide I wanted to share it, I wouldn’t want my get-rich-quick system to become general knowledge. The effectiveness would eventually disappear and I’d be forced to write books or something for a living. No, I would share it with a few friends or perhaps become a private mentor to a select few. But I wouldn’t sell it to the masses.

So next time you’re frustrated with your trading and want a quick way to start having success, look very hard at websites or people offering you an easy ride for a fee. The fact that they have to sell it makes you wonder how they really make their money. Which speaks directly to the effectiveness of their “system”.