Long Term Bollinger Band Breakout Strategy for ThinkorSwim

Zachc

Zachc

Member
VIP
Warehouse
As promised here are my backtest results and the parameters I used for the backtesting.

Here is the test matrix
LengthExit conditionsTrade SizeRate of Change
Weekly3.5 ATRNone30%
Weekly3.5 ATR5%30%
Weekly3.5 ATRNone20%
Weekly3.5 ATR5%20%
WeeklyBollBand Lower CrossNone30%
WeeklyBollBand Lower Cross5%30%
WeeklyBollBand Lower CrossNone20%
WeeklyBollBand Lower Cross5%20%
Daily3.5 ATRNone30%
Daily3.5 ATR5%30%
Daily3.5 ATRNone20%
Daily3.5 ATR5%20%
DailyBollBand Lower CrossNone30%
DailyBollBand Lower Cross5%30%
DailyBollBand Lower CrossNone20%
DailyBollBand Lower Cross5%20%

I wanted to know what combination of settings would yield a better-expected outcome over a long period while still staying reasonably faithful to the original strategy. I am not going to post the results of all the backtests it would just take to much time, and I already spent enough developing the testing.

First, we will start the purest form of the strategy, and then I will take you through some of the other factors listed above.
Weekly Bollinger Band Cross with 5% position size and a Rate of Change of 30%
This strategy does not fire off that often also the reduction of trades due to the position sizing not allowing trades to be made above the 5% threshold of the capital. Some notable stats are the Max Drawdown of less than 13% and the low losing %.



Next sticking to the weekly stats we will change the ROC to 20% which helps to produce more trades and a better expectancy. I went full hog on this setup and tested it against the entire S&P100 I did this work by hand, so I devoted my time to the higher potential settings.

Some notable stats are the CAGAR upwards of 9.5% a whole 3 points higher than the regular strat and a slightly better max drawdown.




Adding the 3.5 ATR stop reduced the compound annual growth rate to nearly 0%. It nullifies your edge by getting you out of the trades a little too early.

TLDR:
Best settings I have found so far with testing the strategy over 100 individual stocks and 34 years simulated are:
Bollinger Band Upper 2, Lower -1 Rate of Change 20% and fixed position sizing. These results would be much more accurate if I was able to scale the testing portfolio in think or swim but due to the backtesting limitation in TOS it is a fixed position size not taking into account any compound gains in the portfolio.

I am currently working on testing the strategy on the daily time frame, but so far, the weekly settings are wining in comparison.
 
T

tibby42

New member
Thank you for posting this, I agree there needs to be more wiggle room on the are stops so they can perform, especially on a longer term system like this- how hard would it be on thinkorswim to change it to the regime filter 20% / 10% trailing stop, asking as a non-coder. Also, I didn’t know you could backtest a portfolio at all on thinkorswim- pleasantly surprised to hear..couldn’t find anything but ‘onDemand’, still though, i think in the long run for backttesting dedicated software may be in order. i hear amibroker is a good product.
 
Zachc

Zachc

Member
VIP
Warehouse
@tibby42 Next step is adding the more advanced regime filter and posting the updated code. Stay tuned.

TOS does not have the ability to backtest a portfolio. These are individual backtests that I sorted and applied some stats too for convenience only. TOS is missing a lot of components specifically the ability to manage the capital usage and tracking capital over the lifetime of the backtest. Therefore allocations in these backtests are based on 5% of the $10,000 starting portfolio over the lifetime of the test. This eliminates the benefits of compounding and additional profits from dividends etc.
 
J

jacqshen

New member
Warehouse
@Zachc , Thank you so much for all the time and effort you put into this! Can't wait to utilize the script but for some reason after adding to my scripts I'm not seeing it there when I try to add it in my studies? I've never experienced this before and just wondering if anyone else has had this issue or has any insight on this? Thanks in advance!
 
mc01439

mc01439

Member
VIP
Warehouse
As promised here are my backtest results and the parameters I used for the backtesting.

Here is the test matrix
LengthExit conditionsTrade SizeRate of Change
Weekly3.5 ATRNone30%
Weekly3.5 ATR5%30%
Weekly3.5 ATRNone20%
Weekly3.5 ATR5%20%
WeeklyBollBand Lower CrossNone30%
WeeklyBollBand Lower Cross5%30%
WeeklyBollBand Lower CrossNone20%
WeeklyBollBand Lower Cross5%20%
Daily3.5 ATRNone30%
Daily3.5 ATR5%30%
Daily3.5 ATRNone20%
Daily3.5 ATR5%20%
DailyBollBand Lower CrossNone30%
DailyBollBand Lower Cross5%30%
DailyBollBand Lower CrossNone20%
DailyBollBand Lower Cross5%20%

I wanted to know what combination of settings would yield a better-expected outcome over a long period while still staying reasonably faithful to the original strategy. I am not going to post the results of all the backtests it would just take to much time, and I already spent enough developing the testing.

First, we will start the purest form of the strategy, and then I will take you through some of the other factors listed above.
Weekly Bollinger Band Cross with 5% position size and a Rate of Change of 30%
This strategy does not fire off that often also the reduction of trades due to the position sizing not allowing trades to be made above the 5% threshold of the capital. Some notable stats are the Max Drawdown of less than 13% and the low losing %.



Next sticking to the weekly stats we will change the ROC to 20% which helps to produce more trades and a better expectancy. I went full hog on this setup and tested it against the entire S&P100 I did this work by hand, so I devoted my time to the higher potential settings.

Some notable stats are the CAGAR upwards of 9.5% a whole 3 points higher than the regular strat and a slightly better max drawdown.




Adding the 3.5 ATR stop reduced the compound annual growth rate to nearly 0%. It nullifies your edge by getting you out of the trades a little too early.

TLDR:
Best settings I have found so far with testing the strategy over 100 individual stocks and 34 years simulated are:
Bollinger Band Upper 2, Lower -1 Rate of Change 20% and fixed position sizing. These results would be much more accurate if I was able to scale the testing portfolio in think or swim but due to the backtesting limitation in TOS it is a fixed position size not taking into account any compound gains in the portfolio.

I am currently working on testing the strategy on the daily time frame, but so far, the weekly settings are wining in comparison.
@Zackc - Added an SPX greater than 200 SMA filter and used 20% of equity. Note the max draw-down, most could not handle. Also did not perform well over the last four years @ -9%, +2%, -9% and +3% YTD 2019

All TradesLong TradesShort TradesBenchmark Buy & Hold (SPX)
Starting Capital
$25,000.00​
$25,000.00​
$25,000.00​
$25,000.00​
Ending Capital
$1,062,377.55​
$1,062,377.55​
$25,000.00​
$193,864.41​
Net Profit
$1,037,377.55​
$1,037,377.55​
$0.00​
$168,864.41​
Net Profit %
4149.51%​
4149.51%​
0.00%​
675.46%​
Annualized Gain %
14.45%​
14.45%​
0.00%​
7.65%​
Exposure
36.10%​
36.10%​
0.00%​
99.76%​
Total Commission
($821.70)​
($821.70)​
$0.00​
($4.95)​
Return on Cash
$0.00​
$0.00​
$0.00​
$0.00​
Margin Interest Paid
$0.00​
$0.00​
$0.00​
$0.00​
Dividends Received
$0.00​
$0.00​
$0.00​
$0.00​
Number of Trades
84​
84​
0​
1​
Average Profit
$12,349.73​
$12,349.73​
$0.00​
$168,864.41​
Average Profit %
27.90%​
27.90%​
0.00%​
681.15%​
Average Bars Held
144.26​
144.26​
0​
6,995.00​
Winning Trades
43​
43​
0​
1​
Win Rate
51.19%​
51.19%​
0.00%​
100.00%​
Gross Profit
$1,667,855.70​
$1,667,855.70​
$0.00​
$168,864.41​
Average Profit
$38,787.34​
$38,787.34​
$0.00​
$168,864.41​
Average Profit %
68.27%​
68.27%​
0.00%​
681.15%​
Average Bars Held
215.07​
215.07​
0​
6,995.00​
Max Consecutive Winners
7​
7​
0​
1​
Losing Trades
41​
41​
0​
0​
Loss Rate
48.81%​
48.81%​
0.00%​
0.00%​
Gross Loss
($630,478.15)​
($630,478.15)​
$0.00​
$0.00​
Average Loss
($15,377.52)​
($15,377.52)​
$0.00​
$0.00​
Average Loss %
-14.43%​
-14.43%​
0.00%​
0.00%​
Average Bars Held
70​
70​
0​
0​
Max Consecutive Losses
8​
8​
0​
0​
Maximum Drawdown
($305,708.84)​
($305,708.84)​
$0.00​
($57,760.31)​
Maximum Drawdown Date
6/24/2013​
6/24/2013​
12/2/1991​
3/9/2009​
Maximum Drawdown %
-50.70%​
-50.70%​
0.00%​
-56.66%​
Maximum Drawdown % Date
4/17/2000​
4/17/2000​
9/11/2019​
3/9/2009​
Wealth-Lab Score
19.74​
19.74​
0​
3.33​
Sharpe Ratio
0.67​
0.67​
0​
0.6​
Profit Factor
2.65​
2.65​
0​
Recovery Factor
3.39​
3.39​
0​
2.92​
Payoff Ratio
4.73​
4.73​
0​
0​
Profit / Total Bars
$148.28​
$148.28​
$0.00​
$24.14​



 

Top