Bollinger Bands Trading System

Post anything related to mechanical systems and automated trading here.
Post Reply
hjelmstade
Posts: 34
Joined: Wed May 18, 2016 6:51 pm
Contact:

Bollinger Bands Trading System

Post by hjelmstade » Sat Oct 01, 2016 11:23 pm

Hi guys,

I have been building a variety of trading systems over the last four months and am ready to share a couple. My only request is to please share any improvements or modifications you make with the community as well.

Lastly, before we get to the nuts and bolts, I wanted to give a big thanks to Earik.

Earik, your Mechanical Trading Systems book was worth every penny and most of the systems I will be sharing would not have been possible without the many lessons you learned the hard way. Thank you.


Code is posted here: http://www.wave59.com/library/scriptdetail.asp?id=174

While this could work as a stand alone system, I'm using a slightly modified version that returns a vote that is then combined with votes from other systems before placing a trade. For this modified system, I'm using Mode 4 but if I was to use this to trade by itself, I would use Mode 2 as this is shown to be the most profitable on an ES Daily chart as demonstrated in the back testing results below.

STRATEGY
This system takes advantage of the markets tendency to over extend itself and places trades in opposite direction of this over extension. This means that interaction with the upper band will initiate a short trade and interaction with the lower band will initiate a long trade.

INPUTS
contracts - number of contracts to trade (value is doubled if you enable modes #2 or #4)
length - length of bollinger band
sdev - standard deviation for bollinger band
profit_exit_bars - if profitable, how many bars to hold before exiting
loss_exit_bars - if not profitable, how many bars to hold before exiting

MODES
The price can interact with a bollinger band in the following ways.

1. Open
2. Close
3. High
4. Low

The various modes are based off these different types of interactions and they each have their pros and cons. If you are merging this system with another, you may find a different mode is appropriate than if you were to run this as a stand alone system. This is what I discovered as mentioned above so be sure to put them all through the optimizer. Also, this goes without saying but different parameters will be ideal for different modes and different time frames.

The only interaction I have yet to explore is the open. So if anyone wants to explore this interaction, you might be able to make additional improvements. Off the top of my head, it would be interesting to see if an accurate trade signal was generated if the open was to occur above or below one of the bands and then move back inside the band.

Mode 1 - Go long if close is <= lower band and short if close >= upper band.

Mode 2 - Go long if close is <= lower band and short if close >= upper band. If the high is <= lower band, go long double the standard trade size. If the low is >= upper band, go short double the standard trade size.

Mode 3 - Go long if low <= lower band and short if high >= upper band.

Mode 4 - Go long if low <= lower band and short if high >= upper band. If the high is <= lower band, go long double the standard trade size. If the low is >= upper band, go short double the standard trade size.

Mode 5 - Go long standard trade size if high <= lower band and short standard trade size if low >= upper band. This mode contains only the logic that doubles the trade size in modes 2 and 4. Under properly optimized parameters, this will happen infrequently but when it does, it tends to be very accurate and profitable. I included this as a stand alone mode as I know this will be useful to integrate into future systems when you need accurate and powerful signals.

FILTERS
Short Filter - Only go short on up or flat close (close >= open)

Loss filter - If systems exits for a loss, do not take a trade in the same direction on the same bar. Example: if we go long and exit x bars later for a loss, do not initiate another long trade on that same bar.

EXIT SYSTEM
Exit and Reverse - Exit and reverse trade if opposite signal generated. Example: if long and mode 1 is selected, exit long and initiate short if close >= upper band

Profit Exit - Exit after >= profit_exit_bars, trade is profitable and profit was not increased on last bar (if long this looks like close < close[1]). This helps to extend profit as we do not want to exit if trend is still moving in our favor. I experimented with checking the trend by comparing previous highs and previous lows but found close to be the most reliable.

Loss Exit - Exit after >= loss_exit_bars and trade is not profitable.


OPTIMIZED PARAMETERS AND EXAMPLES
All of the following parameters and back testing results were performed on a ES daily chart from 9/9/1997 to 9/30/2016. If you have IQFeed, I was using "@ES#".

Mode 1 and 2 Parameters
length: 12
sdev: 1.2
profit_exit_bars: 4
loss_exit_bars: 9


Mode 3 and 4 Parameters
length: 12
sdev: 1.4
profit_exit_bars: 3
loss_exit_bars: 8

Please see attachments for back testing results.

Let me know if you have any questions or comments!
Attachments
daily_ES_backtesting_without_double_highlow_outside_summary.png
Mode 1 Summary
daily_ES_backtesting_without_double_highlow_outside_summary.png (20.15 KiB) Viewed 9250 times
daily_ES_backtesting_summary.png
Mode 2 Summary. Note how adding the doubling trade strategy under the rare circumstances described in the post did not increase drawdown.
daily_ES_backtesting_summary.png (20.17 KiB) Viewed 9250 times
daily_ES_backtesting_equitycurve.png
Mode 2 Equity Curve
daily_ES_backtesting_equitycurve.png (14.33 KiB) Viewed 9250 times
daily_ES_backtesting_summary.png
Mode 4 Summary
daily_ES_backtesting_summary.png (20.05 KiB) Viewed 9250 times
daily_ES_backtesting_equitycurve.png
Mode 4 Equity Curve
daily_ES_backtesting_equitycurve.png (12.44 KiB) Viewed 9250 times

orionsbelt
Posts: 33
Joined: Tue Jul 21, 2015 9:19 pm
Contact:

Re: Bollinger Bands Trading System

Post by orionsbelt » Sat Jan 14, 2017 5:46 pm

great job hjelmstade
here is some food for thought of a possibility to maybe expand or improve the BB systems
what about incorporating a BB with a 1 and a 2 standard deviation which would form an outer channel of sorts.
maybe we can come up with some addition ideas with this. maybe take advantage of trend moves, buy only in upper outer channel. opposite for sells.
please see following article for a general overview

Code: Select all

http://www.investopedia.com/articles/trading/05/022205.asp?lgl=bt1tn-no-widget
just trying to throw out other ideas we can expand upon

thanks

hjelmstade
Posts: 34
Joined: Wed May 18, 2016 6:51 pm
Contact:

Re: Bollinger Bands Trading System

Post by hjelmstade » Sat Jan 14, 2017 11:53 pm

Hi orionsbelt,

Thats great, thanks for sharing. I haven't used bollinger bands like that before and can think of a lot of applications outside of just this system :D

I'm adding this to my to do list and will see what I can come up with. It might be a little while depending on how busy my day job is but I'll update here once I have something.

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest