Repaints Bollinger Bands MTF (Multi Time Frame) for ThinkorSwim

Repaints

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Someone recently asked if it was possible to plot Bollinger Bands from 15m on the 5m chart. The answer is yes, using this indicator.

Example: Displaying the Bollinger Bands of the Hourly chart on the 5m, 15m, or 30m time frame. The indicator is highly configurable and support multi time frame options.

The original version has the simple moving average set to 50 and standard deviation set to 1.0. I modified it so that it is up to date with the Bollinger Bands indicator in ThinkorSwim. You can adjust the values and settings to your liking.

4vj2DTK.png

WnfNAUg.png


thinkScript Code

Code:
# DG_MTFBollingerBands
# Paints Bollinger Bands from higher time period
# onto current time period
#
# Copyright (c) 2017 Daniel Granville

input timeframe = AggregationPeriod.DAY;
input period = 20;
input std = 2.0;
input moving_average_type = {default SMA, EMA};

def data = close(period = timeframe);
def band = StDev(data, period);

plot MidLine;

switch(moving_average_type) {
    case SMA:
        MidLine = Average(data, period);
    case EMA:
        MidLine = ExpAverage(data, period);
}

plot BBandTop = MidLine + band;

plot BBandBot = MidLine - band;

Credit:
 

Attachments

  • 4vj2DTK.png
    4vj2DTK.png
    98.9 KB · Views: 299
  • WnfNAUg.png
    WnfNAUg.png
    138 KB · Views: 295
Last edited:
From <http://sureshgundappa.blogspot.com/2013/07/15-basic-rules-for-using-bollinger-bands.html>

1. Bollinger Bands provide a relative definition of high and low.

2. That relative definition can be used to compare price action and indicator action to arrive at rigorous buy and sell decisions.

3. Appropriate indicators can be derived from momentum, volume, sentiment, open interest, inter-market data, etc.

4. Volatility and trend already have been deployed in the construction of Bollinger Bands, so their use for confirmation of price action is not recommended.

5. The indicators used for confirmation should not be directly related to one another.
Two indicators from the same category do not increase confirmation. Avoid colinearity.

6. Bollinger Bands can be used to clarify pure price patterns, such as M-type tops and W-type bottoms, momentum shifts, etc.

7. Price can—and does—walk up the upper Bollinger Band and down the lower Bollinger Band.

8. Closes outside the Bollinger Bands can be continuation signals, not reversal signals—as is demonstrated by the use of Bollinger Bands in some very successful volatility-breakout systems.

9. The default parameters of 20 periods for the moving average and standard deviation calculations, and the two standard deviations for the bandwidth are just that, defaults. The actual parameters needed for any given market/task may be different.

10. The average deployed should not be the best one for crossover signals. Rather, it should be descriptive of the intermediate-term trend.

11. If the average is lengthened, the number of standard deviations needs to be increased simultaneously; from 2 at 20 periods, to 2.1 at 50 periods.
Likewise, if the average is shortened, the number of standard deviations should be reduced; from 2 at 20 periods, to 1.9 at 10 periods.

12. Bollinger Bands are based upon a simple moving average. This is because a simple moving average is used in the standard deviation calculation and we wish to be logically consistent.

13. Be careful about making statistical assumptions based on the use of the standard deviation calculation in the construction of the bands.
The sample size in most deployments of Bollinger Bands is too small for statistical significance, and the distributions involved are rarely normal.

14. Indicators can be normalized with %b, eliminating fixed thresholds in the process.

15. Finally, tags of the bands are just that, tags, not signals. A tag of the upper Bollinger Band is NOT in-and-of-itself a sell signal.
A tag of the lower Bollinger Band is NOT in-and-of-itself a buy signal.
 
Please can someone explain how this is useful over using 2 BB studies of same time frame with different dev.
 
Actually, there was at least one study in TASC a while back by Tushar Chande.
It used 4 different Time Frames in BB's plus a few more studies to create a Combined Signal Approach (CSA).
Usefull? Maybe, but I didn't look at it beyond reading about it.
 
Hello all, I like the concept of this indicator but need help with it since I'm not a coder but learning. This indicator
# Paints Bollinger Bands from higher time period
# onto current time period
First, I don't see the specific time periods named in the code so I figured it is so one can modify it, but I don't know if instead of the word time I'm supposed to type 1hr, 4hr, day or if it's one period at a time and for example should be AggregationPeriod.1hr;
and since it is BB shouldn't have def or input Bollinger Bands named in the code.
Then, I would like to use it in the opposite direction from which it was created. Instead of
# Paints Bollinger Bands from higher time period
# onto current time period
I would like to have a weekly chart and
# Paints Bollinger Bands from lower time period
# onto current (weekly) time period
so on my current weekly 1Y:Wk chart I would like to have BB from current 1D (day), current 4hr or 1hr time period. Also, I don't understand
plot BBandTop = MidLine + band;
plot BBandBot = MidLine - band;
How does it add/subtract from top/bottom band the 20 ema or sma to 2.0 STD outer bands? If this is possible as a mathematical equation wouldn'the resu;t be more than 2.0 STD for the outer bands? Apologies for my lack of knowledge and thanks in advance.
 
Last edited:
Wonderful, that answers my question for 2 indicators I'm studying.
What's up with the BB outer bands are they more than 2.0 std with this addition?

I don't understand
plot BBandTop = MidLine + band;
plot BBandBot = MidLine - band;
How does it add/subtract from top/bottom band the 20 ema or sma to 2.0 STD outer bands? If this is possible as a mathematical equation wouldn'the resu;t be more than 2.0 STD for the outer bands?
 
@BenTen. This is awesome. Thank you! Assuming one could make this work for Tick charts? i.e. instead of selecting the timeframe as an input, selecting a tick size. E.g. I would like to show the 1500 Tick Aggregation Period Bollinger on a 150 Tick chart. Please let me know if you have any ideas. Thank you. :)

I've added relevant information about myself in my user signature as per your request.
 
Last edited by a moderator:
Someone recently asked if it was possible to plot Bollinger Bands from 15m on the 5m chart. The answer is yes, using this indicator.

Example: Displaying the Bollinger Bands of the Hourly chart on the 5m, 15m, or 30m time frame. The indicator is highly configurable and support multi time frame options.

The original version has the simple moving average set to 50 and standard deviation set to 1.0. I modified it so that it is up to date with the Bollinger Bands indicator in ThinkorSwim. You can adjust the values and settings to your liking.

4vj2DTK.png

WnfNAUg.png


thinkScript Code

Code:
# DG_MTFBollingerBands
# Paints Bollinger Bands from higher time period
# onto current time period
#
# Copyright (c) 2017 Daniel Granville

input timeframe = AggregationPeriod.DAY;
input period = 20;
input std = 2.0;
input moving_average_type = {default SMA, EMA};

def data = close(period = timeframe);
def band = StDev(data, period);

plot MidLine;

switch(moving_average_type) {
    case SMA:
        MidLine = Average(data, period);
    case EMA:
        MidLine = ExpAverage(data, period);
}

plot BBandTop = MidLine + band;

plot BBandBot = MidLine - band;

Credit:
can we just plot one day's worth of the bollinger band ( Instead of hanving all of the days lines on the chart) just todays band position?
 
Code:
input std = 2.0;

This std variable is never used in this or dgranville's original indicator, which causes us to draw the Bollinger Band at 1 standard deviation. I think this update will solve the problem:

Code:
# DG_MTFBollingerBands
# Paints Bollinger Bands from higher time period
# onto current time period
#
# Copyright (c) 2017 Daniel Granville

input timeframe = AggregationPeriod.DAY;
input period = 20;
input std = 2.0;
input moving_average_type = {default SMA, EMA};

def data = close(period = timeframe);
def band = StDev(data, period);

plot MidLine;

switch(moving_average_type) {
    case SMA:
        MidLine = Average(data, period);
    case EMA:
        MidLine = ExpAverage(data, period);
}

plot BBandTop = MidLine + (band * std);

plot BBandBot = MidLine - (band * std);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
252 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top