• LIMITED TIME OFFER: use coupon code PRIMEDAY (case sensitive) at checkout to save $50 off VIP membership (down to $149 / year). Valid through Tuesday 6/22. Biggest discount this year!

Bollinger Bands MTF (Multi Time Frame) for ThinkorSwim

BenTen

Administrative
Staff
VIP
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:
 
Last edited:

markos

Well-known member
VIP
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.
 

horserider

Well-known member
VIP
Please can someone explain how this is useful over using 2 BB studies of same time frame with different dev.
 

markos

Well-known member
VIP
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.
 

soary

Member
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:

BenTen

Administrative
Staff
VIP

soary

Member
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?
 

visag9

New member
@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:

Similar threads

Top