# German's Channels for ThinkorSwim

#### GERMANB1990

##### New member
So this idea combines Bollinger bands and McGinley's Dynamic moving average with fractal dimension to get bands that will be more reactive to current price and speed of current price, hopefully this will work, have not tested it out real time, as well as if you guys have more ideas to fix this your more than welcome to fix or move things around, the settings that seem to work well are 21, 3, 9.

Code:
``````#  D = D[1] + (I - D[1]) / ( N * (I/D[1])^4)
# where D[1] = yesterday's Dynamic, I = today's price, N = smoothing factor.
# Self Adjusting with Fractal Dimensions Algorithm
#re-labelled MDI with 'a' to avoid conflict with above script

input I = close;
input N = 10;
input AscaleLow = 3;
input AscaleHigh = 10;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;

def o;

def h;

def l;

def c;

def TR;

def B;
def sDev = stdev(data = I, length = N);
def Ascaled;

# Internal Script

script Scale {

input c = close;

input Min = .01;

input Max =   1;

def hh = HighestAll(c);

def ll   = LowestAll(c);

plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;

}

# Calculations

o = (open + close[1]) / 2;

h = Max(high, close[1]);

l = Min(low, close[1]);

c = (o + h + l + close) / 4;

TR = Max(h, c[1]) - Min(l, c[1]);

B = (Log(Sum(TR, N) / (Highest(h, N) - Lowest(l, N)))

/ Log(10)) / (Log(N) / Log(10));

Ascaled = Round(Scale(c = B, min = AscaleLow, max = AscaleHigh), 2);

def D;

D = CompoundValue(1, D[1] + (I - D[1]) /  Ascaled * (Power((I / D[1]), 4)), I);

plot MDIa = D;

MDIa.SetPaintingStrategy(PaintingStrategy.LINE);

MDIa.SetLineWeight(2);

mdia.AssignValueColor(if mdia < mdia[1] then Color.red else if mdia > mdia[1] then Color.green else Color.white);

MDIa.SetDefaultColor(GetColor(8));

addlabel(1, ( "McGinley Frac=" + MDIa ), if mdia < mdia[1] then color.magenta else color.cyan);

plot LowerBand = D + num_Dev_Dn * sDev;
plot UpperBand = D + num_Dev_Up * sDev;``````

#### mailbagman2000

##### Member
VIP
Do you have a SCAN script for this?

#### hectorgasm

##### Member
So this idea combines Bollinger bands and McGinley's Dynamic moving average with fractal dimension to get bands that will be more reactive to current price and speed of current price, hopefully this will work, have not tested it out real time, as well as if you guys have more ideas to fix this your more than welcome to fix or move things around, the settings that seem to work well are 21, 3, 9.

Code:
``````#  D = D[1] + (I - D[1]) / ( N * (I/D[1])^4)
# where D[1] = yesterday's Dynamic, I = today's price, N = smoothing factor.
# Self Adjusting with Fractal Dimensions Algorithm
#re-labelled MDI with 'a' to avoid conflict with above script

input I = close;
input N = 10;
input AscaleLow = 3;
input AscaleHigh = 10;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;

def o;

def h;

def l;

def c;

def TR;

def B;
def sDev = stdev(data = I, length = N);
def Ascaled;

# Internal Script

script Scale {

input c = close;

input Min = .01;

input Max =   1;

def hh = HighestAll(c);

def ll   = LowestAll(c);

plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;

}

# Calculations

o = (open + close[1]) / 2;

h = Max(high, close[1]);

l = Min(low, close[1]);

c = (o + h + l + close) / 4;

TR = Max(h, c[1]) - Min(l, c[1]);

B = (Log(Sum(TR, N) / (Highest(h, N) - Lowest(l, N)))

/ Log(10)) / (Log(N) / Log(10));

Ascaled = Round(Scale(c = B, min = AscaleLow, max = AscaleHigh), 2);

def D;

D = CompoundValue(1, D[1] + (I - D[1]) /  Ascaled * (Power((I / D[1]), 4)), I);

plot MDIa = D;

MDIa.SetPaintingStrategy(PaintingStrategy.LINE);

MDIa.SetLineWeight(2);

mdia.AssignValueColor(if mdia < mdia[1] then Color.red else if mdia > mdia[1] then Color.green else Color.white);

MDIa.SetDefaultColor(GetColor(8));

addlabel(1, ( "McGinley Frac=" + MDIa ), if mdia < mdia[1] then color.magenta else color.cyan);

plot LowerBand = D + num_Dev_Dn * sDev;
plot UpperBand = D + num_Dev_Up * sDev;``````
does it repaint?