Keltner Channel Upper/Lower Clouds, Scans, Signals for ThinkorSwim

asianboy

New member
Found something very cool

SPX+PercentK.png


It is a lower indicator with Price Bar Coloring options are as follows:

- Bright_Green: Both Short term and Long term trends are Up,
- Bright_Green: Both Short term and Long term trends are Up,
- Bright_Red: Both Short term and Long term trends are Down,
- Light_Red: Short term trend is Down and Long term trend is Up,
- Yellow: If ChopColor is selected yes, then all Price Bars occurring during Choppiness
periods per the Trend Strength Label (discussed below) will be colored.

thinkScript Code

Code:
# KC_PercentK V1_R2

# KeltnerChannels set to similar BB PercentB

# Developed by Lar with assistance from TrendXplorer

# Trending and Squeeze Indicators provided by Mobius @My Trade

# Orange dots indicate squeeze.

# Orange Label indicates Squeeze status and number of consecutive bars being squeezed.

# The longer the squeeze is lasting may indicate a larger move when it ends.

#

# Green dots on zero line indicate trend direction is up.

# Red dots on zero line indicate trend is down.

#

# Cloud colors indicate short term price action green/red and long term

# dark_green/dark_red.

#

# Trend Strength label is worded Trending and color coded to be light_green (weak)

# and green (strong) for uptrends and light_red (weak) and red (strong) for downtrends.

# It is worded Choppy and color coded light_green/light_red for Choppiness.

#

# Coloring of Price bars can be selected:

# - Bright Green = Both Short term and Long term trends are Up,

# - Light Green = Short term trend is Up and Long term trends is Down,

# - Bright Red = Both Short term and Long term trends are Down,

# - Light Red = Short term trend is Down and Long term trend is Up.

# During uptrends, light red colors may indicate a pullback if light red cloud is

# shrinking or above -100 and then Green dots continue. Otherwise, a possible trend

# reversal is indicated. The opposite applies for downtrends.

#

# Coloring of Price bars for Choppiness can be selected. Yellow = Bars in Chop.

declare lower;

input pricecolor    = yes;

input chopcolor = no; #Hint chopcolor: Choose yes to have Price bars colored Yellow while the trend is CHOPPY.

def price = close;

def displace = 0;

def h = high;

def l = low;

def c               = close;

# Keltner Channel set similar to BollingerBands PercentB by Lar  (Longer Term Trend)

def factorKCLT = 1.500;

def lengthKCLT   = 20.000;

def shiftKCLT   = factorKCLT * AvgTrueRange(h, c, l, lengthKCLT);

def averageKCLT = SimpleMovingAvg(price, lengthKCLT);

def AvgKCLT = averageKCLT[-displace];

def Upper_BandKCLT = averageKCLT[-displace] + shiftKCLT[-displace];

def Lower_BandKCLT = averageKCLT[-displace] - shiftKCLT[-displace];

plot PercentkLT = (price - Lower_BandKCLT) / (Upper_BandKCLT - Lower_BandKCLT) * 100;

PercentkLT.AssignValueColor(if PercentkLT > 0 then Color.GREEN else Color.RED);

PercentkLT.SetLineWeight(1);

PercentkLT.Hide();

# Keltner Channel set similar to BollingerBands PercentB by Lar (Shorter Term Trend)

def factorKCST = .500;

def lengthKCST   = 6.000;

def shiftKCST   = factorKCST * AvgTrueRange(h, c, l, lengthKCST);

def averageKCST = SimpleMovingAvg(price, lengthKCST);

def AvgKCST = averageKCST[-displace];

def Upper_BandKCST = averageKCST[-displace] + shiftKCST[-displace];

def Lower_BandKCST = averageKCST[-displace] - shiftKCST[-displace];

plot PercentkST = (price - Lower_BandKCST) / (Upper_BandKCST - Lower_BandKCST) * 100;

PercentkST.AssignValueColor(if PercentkST > 0 then Color.GREEN else Color.RED);

PercentkST.SetLineWeight(1);

PercentkST.HideBubble();

# Trends Defined

# Long Term Trend

rec Uptrend = if Uptrend[1] == 0 and PercentkLT >= 0 then 1 else if Uptrend[1] == 1 and PercentkLT >= 0 then 1 else 0;

rec Downtrend = if Uptrend == 0 then 1 else 0;

# Short Term Trend

rec uptrendsmall = if uptrendsmall[1] == 0 and PercentkST >= 0 then 1 else if uptrendsmall[1] == 1 and PercentkST >= 0 then 1 else 0;

rec downtrendsmall = if uptrendsmall == 0 then 1 else 0;

# Line Definitions

def ZeroLine = if !IsNaN(price) then 0 else Double.NaN;

def HalfLine = if !IsNaN(price) then 50 else Double.NaN;

def UnitLine = if !IsNaN(price) then 100 else Double.NaN;

# Clouds

AddCloud(PercentkST, ZeroLine, Color.GREEN, Color.RED);

AddCloud(PercentkST, PercentkLT, Color.GREEN, Color.RED);

# Choppiness Indicator from Mobius @My Trade with color changes by Lar

# Set ADX & SMA to how you trade

# Indicates Trending or Chop along with current ADX level

def ADXLength    = 5; # TOS default 10

def SMALength = 8; # TOS default 8

def Lengthchop = 8;

def Signal = 3;

def Choppy = 61.8;

def MidLine = 50;

def Trending     = 38.2;

def ADX = Round(reference ADX(length = ADXLength), 0);

def SMA = Average(price, SMALength);

def CIB = ((Log(Sum(TrueRange(h, c, l), Lengthchop) /

(Highest(if h >= c[1] then h else

c[1], Lengthchop) -

Lowest( if l <= c[1] then l else c[1], Lengthchop)))

/ Log(10)) / (Log(Lengthchop) / Log(10))) * 100;

def CI = CIB;

def Mid = MidLine;

def Trend1 = Trending;

def TrendLine = 0;

# Plot of Trends

plot trend = if uptrendsmall == 1 or downtrendsmall == 1 then TrendLine else Double.NaN;

trend.SetPaintingStrategy(PaintingStrategy.POINTS);

trend.AssignValueColor(if Uptrend == 1 and uptrendsmall == 1 then createcolor(0,214,0) else if uptrendsmall == 1 and Uptrend == 0 then createcolor(138,255,138) else if Downtrend == 1 and downtrendsmall == 1 then createcolor(204,0,0) else if downtrendsmall == 1 and Downtrend == 0 then createcolor(255,51,51) else Color.YELLOW);

trend.SetLineWeight(1);

trend.HideBubble();

# Choppiness Indicator Label

AddLabel(yes, if CI > MidLine then "CHOPPY " + ADX else "TRENDING " + ADX, if CI < Trend1 then (if uptrendsmall == 1 then Color.GREEN else Color.RED) else if CI > Trend1 and CI < MidLine then (if uptrendsmall == 1 then Color.LIGHT_GREEN else Color.LIGHT_RED) else if CI > MidLine and uptrendsmall == 1 then Color.LIGHT_GREEN else Color.LIGHT_RED);

# Squeeze by Mobius @ My Trade with color mod by Lar

# Look at Cloud Color as a possible indication of direction once squeeze ends

def nK = 1.5;

def nBB = 2.0;

def lengthsqueeze = 20;

def BBHalfWidth = StDev(price, lengthsqueeze);

def KCHalfWidth = nK * AvgTrueRange(h, c, l, lengthsqueeze);

def isSqueezed  =  nBB * BBHalfWidth / KCHalfWidth < 1;

# Squeeze for Longer Term Trend Indicator

plot BBS_Ind = if isSqueezed then TrendLine else Double.NaN;

BBS_Ind.SetDefaultColor(Color.DARK_ORANGE);

BBS_Ind.SetPaintingStrategy(PaintingStrategy.POINTS);

BBS_Ind.SetLineWeight(4);

BBS_Ind.HideBubble();

# Count of Periods in consecutive squeeze

rec count = if isSqueezed then count[1] + 1 else 0;

AddLabel(yes, if isSqueezed then Concat("Squeeze ", count) else "No Squeeze", Color.DARK_ORANGE);

# Paint Price Bars

assignPriceColor(if pricecolor==yes then if uptrendsmall==1 and CI > MidLine and chopcolor==yes then Color.yellow else if uptrendsmall==1 and uptrend==1 then createcolor(0,214,0) else if Uptrend==0 and Uptrendsmall==1 then createcolor(138,255,138) else if  Downtrendsmall==1 and CI > MidLine and chopcolor==yes then Color.yellow else if Downtrend==1 and downtrendsmall==1 then createcolor(204,0,0) else if downtrend==0 and downtrendsmall==1 then createcolor(255,51,51) else color.current else color.current);

SOURCE* https://indexswingtrader.blogspot.com/2013/01/guestpost-by-lar-kcpercentk.html
 
Last edited by a moderator:
Backtesting this now and it already seems extremely helpful, very interesting find! Thank you for sharing.
 
Found something very cool

SPX+PercentK.png


It is a lower indicator with Price Bar Coloring options are as follows:

- Bright_Green: Both Short term and Long term trends are Up,
- Bright_Green: Both Short term and Long term trends are Up,
- Bright_Red: Both Short term and Long term trends are Down,
- Light_Red: Short term trend is Down and Long term trend is Up,
- Yellow: If ChopColor is selected yes, then all Price Bars occurring during Choppiness
periods per the Trend Strength Label (discussed below) will be colored.

thinkScript Code

Code:
# KC_PercentK V1_R2

# KeltnerChannels set to similar BB PercentB

# Developed by Lar with assistance from TrendXplorer

# Trending and Squeeze Indicators provided by Mobius @My Trade

# Orange dots indicate squeeze.

# Orange Label indicates Squeeze status and number of consecutive bars being squeezed.

# The longer the squeeze is lasting may indicate a larger move when it ends.

#

# Green dots on zero line indicate trend direction is up.

# Red dots on zero line indicate trend is down.

#

# Cloud colors indicate short term price action green/red and long term

# dark_green/dark_red.

#

# Trend Strength label is worded Trending and color coded to be light_green (weak)

# and green (strong) for uptrends and light_red (weak) and red (strong) for downtrends.

# It is worded Choppy and color coded light_green/light_red for Choppiness.

#

# Coloring of Price bars can be selected:

# - Bright Green = Both Short term and Long term trends are Up,

# - Light Green = Short term trend is Up and Long term trends is Down,

# - Bright Red = Both Short term and Long term trends are Down,

# - Light Red = Short term trend is Down and Long term trend is Up.

# During uptrends, light red colors may indicate a pullback if light red cloud is

# shrinking or above -100 and then Green dots continue. Otherwise, a possible trend

# reversal is indicated. The opposite applies for downtrends.

#

# Coloring of Price bars for Choppiness can be selected. Yellow = Bars in Chop.

declare lower;

input pricecolor    = yes;

input chopcolor = no; #Hint chopcolor: Choose yes to have Price bars colored Yellow while the trend is CHOPPY.

def price = close;

def displace = 0;

def h = high;

def l = low;

def c               = close;

# Keltner Channel set similar to BollingerBands PercentB by Lar  (Longer Term Trend)

def factorKCLT = 1.500;

def lengthKCLT   = 20.000;

def shiftKCLT   = factorKCLT * AvgTrueRange(h, c, l, lengthKCLT);

def averageKCLT = SimpleMovingAvg(price, lengthKCLT);

def AvgKCLT = averageKCLT[-displace];

def Upper_BandKCLT = averageKCLT[-displace] + shiftKCLT[-displace];

def Lower_BandKCLT = averageKCLT[-displace] - shiftKCLT[-displace];

plot PercentkLT = (price - Lower_BandKCLT) / (Upper_BandKCLT - Lower_BandKCLT) * 100;

PercentkLT.AssignValueColor(if PercentkLT > 0 then Color.GREEN else Color.RED);

PercentkLT.SetLineWeight(1);

PercentkLT.Hide();

# Keltner Channel set similar to BollingerBands PercentB by Lar (Shorter Term Trend)

def factorKCST = .500;

def lengthKCST   = 6.000;

def shiftKCST   = factorKCST * AvgTrueRange(h, c, l, lengthKCST);

def averageKCST = SimpleMovingAvg(price, lengthKCST);

def AvgKCST = averageKCST[-displace];

def Upper_BandKCST = averageKCST[-displace] + shiftKCST[-displace];

def Lower_BandKCST = averageKCST[-displace] - shiftKCST[-displace];

plot PercentkST = (price - Lower_BandKCST) / (Upper_BandKCST - Lower_BandKCST) * 100;

PercentkST.AssignValueColor(if PercentkST > 0 then Color.GREEN else Color.RED);

PercentkST.SetLineWeight(1);

PercentkST.HideBubble();

# Trends Defined

# Long Term Trend

rec Uptrend = if Uptrend[1] == 0 and PercentkLT >= 0 then 1 else if Uptrend[1] == 1 and PercentkLT >= 0 then 1 else 0;

rec Downtrend = if Uptrend == 0 then 1 else 0;

# Short Term Trend

rec uptrendsmall = if uptrendsmall[1] == 0 and PercentkST >= 0 then 1 else if uptrendsmall[1] == 1 and PercentkST >= 0 then 1 else 0;

rec downtrendsmall = if uptrendsmall == 0 then 1 else 0;

# Line Definitions

def ZeroLine = if !IsNaN(price) then 0 else Double.NaN;

def HalfLine = if !IsNaN(price) then 50 else Double.NaN;

def UnitLine = if !IsNaN(price) then 100 else Double.NaN;

# Clouds

AddCloud(PercentkST, ZeroLine, Color.GREEN, Color.RED);

AddCloud(PercentkST, PercentkLT, Color.GREEN, Color.RED);

# Choppiness Indicator from Mobius @My Trade with color changes by Lar

# Set ADX & SMA to how you trade

# Indicates Trending or Chop along with current ADX level

def ADXLength    = 5; # TOS default 10

def SMALength = 8; # TOS default 8

def Lengthchop = 8;

def Signal = 3;

def Choppy = 61.8;

def MidLine = 50;

def Trending     = 38.2;

def ADX = Round(reference ADX(length = ADXLength), 0);

def SMA = Average(price, SMALength);

def CIB = ((Log(Sum(TrueRange(h, c, l), Lengthchop) /

(Highest(if h >= c[1] then h else

c[1], Lengthchop) -

Lowest( if l <= c[1] then l else c[1], Lengthchop)))

/ Log(10)) / (Log(Lengthchop) / Log(10))) * 100;

def CI = CIB;

def Mid = MidLine;

def Trend1 = Trending;

def TrendLine = 0;

# Plot of Trends

plot trend = if uptrendsmall == 1 or downtrendsmall == 1 then TrendLine else Double.NaN;

trend.SetPaintingStrategy(PaintingStrategy.POINTS);

trend.AssignValueColor(if Uptrend == 1 and uptrendsmall == 1 then createcolor(0,214,0) else if uptrendsmall == 1 and Uptrend == 0 then createcolor(138,255,138) else if Downtrend == 1 and downtrendsmall == 1 then createcolor(204,0,0) else if downtrendsmall == 1 and Downtrend == 0 then createcolor(255,51,51) else Color.YELLOW);

trend.SetLineWeight(1);

trend.HideBubble();

# Choppiness Indicator Label

AddLabel(yes, if CI > MidLine then "CHOPPY " + ADX else "TRENDING " + ADX, if CI < Trend1 then (if uptrendsmall == 1 then Color.GREEN else Color.RED) else if CI > Trend1 and CI < MidLine then (if uptrendsmall == 1 then Color.LIGHT_GREEN else Color.LIGHT_RED) else if CI > MidLine and uptrendsmall == 1 then Color.LIGHT_GREEN else Color.LIGHT_RED);

# Squeeze by Mobius @ My Trade with color mod by Lar

# Look at Cloud Color as a possible indication of direction once squeeze ends

def nK = 1.5;

def nBB = 2.0;

def lengthsqueeze = 20;

def BBHalfWidth = StDev(price, lengthsqueeze);

def KCHalfWidth = nK * AvgTrueRange(h, c, l, lengthsqueeze);

def isSqueezed  =  nBB * BBHalfWidth / KCHalfWidth < 1;

# Squeeze for Longer Term Trend Indicator

plot BBS_Ind = if isSqueezed then TrendLine else Double.NaN;

BBS_Ind.SetDefaultColor(Color.DARK_ORANGE);

BBS_Ind.SetPaintingStrategy(PaintingStrategy.POINTS);

BBS_Ind.SetLineWeight(4);

BBS_Ind.HideBubble();

# Count of Periods in consecutive squeeze

rec count = if isSqueezed then count[1] + 1 else 0;

AddLabel(yes, if isSqueezed then Concat("Squeeze ", count) else "No Squeeze", Color.DARK_ORANGE);

# Paint Price Bars

assignPriceColor(if pricecolor==yes then if uptrendsmall==1 and CI > MidLine and chopcolor==yes then Color.yellow else if uptrendsmall==1 and uptrend==1 then createcolor(0,214,0) else if Uptrend==0 and Uptrendsmall==1 then createcolor(138,255,138) else if  Downtrendsmall==1 and CI > MidLine and chopcolor==yes then Color.yellow else if Downtrend==1 and downtrendsmall==1 then createcolor(204,0,0) else if downtrend==0 and downtrendsmall==1 then createcolor(255,51,51) else color.current else color.current);

SOURCE* https://indexswingtrader.blogspot.com/2013/01/guestpost-by-lar-kcpercentk.html
Thank you for sharing. I think LAR mis-used the Chop Indicator from Mobius, but if it works for you, that's great.
 
@asianboy thanks I'm trying to figure It out. Anything others tweets I would appreciate or what works best what signs you wait for work best. Thanks!
 
If the MTF can be added we could have a good entry strategy for the reversal setup, is there anyone that can help adding the aggregation?
 
Sorry, I meant the original study. It definitely seems to hang above the zero line much more than below, even on down days. Just wondering why and if it may need tweaking. Seems promising.
 
@tomsk Yes the first study. My point is not that it NEVER goes below zero, my point is that it has a strong tendency to stay above zero, even in down trends. Why is this? Look at AMRN from yesterday on the one minute (Dec 16). It was a horrible day for that stock, and the dark red cloud (long term Keltner) only ever gets to -90ish. BUT, on that same terrible day the dark red cloud gets to 165 twice. The short term, bight red, only ever gets to -208 on a massive down day but the short term bright green gets to a massive 350 reading.

I like the idea of this indicator and would like to use something like it for mean regression scalps, I just don't get why this thing has such a tendency to stay above the zero line. I've looked at many many charts, and if you look at the long term dark red cloud it really wants to stay above the zero line, and I don't believe it's because most stocks go up. I think something else is going on.
 
@dolomick Seems there are easier ways to do mean reversion than this indicator. If it is not making sense move on. Way too many indicators out there to waste time on this one. Maybe try a MA deviation for reversion, that may be the simplest.
 
Hello, I need help with ema-based Keltner to change channel color based on MACD. When macd line crosses +0.3 level, the Keltner channel changes color to cyan. When macd line crosses -0.3 level, the color of channel changes to magenta color.

#The Keltner code from ThinkorSwim

input tolerance = 1.5;
input Length = 15;
input coeff = 2.5;
input hideLines = {Hide_Hi, Hide_Lo, Hide_Both, default Hide_None};

def h_hi;
def h_lo;
switch(hideLines){
case Hide_Hi:
h_hi = 1; h_lo = 0;
case Hide_Lo:
h_hi = 0; h_lo = 1;
case Hide_Both:
h_hi = 1; h_lo = 1;
default:
h_hi = 0; h_lo = 0;
}
def hi_Avg = sum(if(high > high[1],high - high[1],0), Length) / sum(if(high > high[1],1,0), Length);
def hi_line = high[1] + (hi_Avg[1] * coeff);
def hi_max = Min(Min(hi_line, hi_line[1]), hi_line[2]);
plot hi_plot = hi_max;
hi_plot.setStyle(Curve.Short_Dash);
hi_plot.setHiding(h_hi);

def lo_Avg = sum(if(low < low[1],low[1] - low,0), Length) / sum(if(low < low[1],1,0), Length);
def lo_line = low[1] - (lo_Avg[1] * coeff);
def lo_max = Max(Max(lo_line, lo_line[1]), lo_line[2]);
plot lo_plot = lo_max;
lo_plot.setStyle(Curve.Short_Dash);
lo_plot.setHiding(h_lo);

plot magic = if( (hi_max-lo_max) <= tolerance, hi_max,double.nan);
magic.setPaintingStrategy(PaintingStrategy.POINTS);
 
Last edited:
I add four band colors to Keltner Channel Indicator to show uptrends and downtrends.
Ruby:
# Partial code is from ThinkorSwim
# Modified by Peter luis

declare weak_volume_dependency;

input displace = 0;
input factor = 1.5;
input length = 20;
input price = close;
input fill =yes;
input averageType = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);

def average = MovingAverage(averageType, price, length);

plot Midline = average[-displace];
Midline.SetDefaultColor(GetColor(1));

plot UpperBand = average[-displace] + shift[-displace];
UpperBand.SetDefaultColor(GetColor(8));

plot LowerBand = average[-displace] - shift[-displace];
LowerBand.SetDefaultColor(GetColor(5));

def a = (UpperBand > UpperBand[1] and Midline > Midline[1]);
def b = (UpperBand < UpperBand[1] and LowerBand < LowerBand[1]);
def c = (UpperBand > UpperBand[1] and Midline > Midline[1]);
def d = (UpperBand < UpperBand[1] and midline < midline[1]);
def e = average(close)>midline;
def f = midline<average(close);
def nan      =   Double.NaN;
def Chg      =   If(a, 1, If(b, -1, 0));
def Hold     =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def Chg_a    =   If((c or e), 1, If((d or f), -1, 0));
def Hold_a   =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def LBUp     =   if fill and Hold[0] == 1 then lowerBand else nan;
def UBUp     =   if fill and Hold[0] == 1 then upperband else nan;
def LBDn     =   if fill and Hold[0] == -1 then lowerband else nan;
def UBDn     =   if fill and Hold[0] == -1 then upperband else nan;
def MBUP     =   if fill and Hold[0] == 1 then midline else nan;
def MBDn     =   if fill and Hold[0] == -1 then Midline else nan;

DefineGlobalColor("Cloud Up", Color.red);
DefineGlobalColor("Cloud_Up", Color.yellow);
DefineGlobalColor("Cloud_Dn", Color.cyan);
DefineGlobalColor("Cloud Dn", Color.green);
AddCloud(LBUp, UBUp, GlobalColor("Cloud Up"), GlobalColor("Cloud Dn"));
AddCloud(LBDn, UBDn, GlobalColor("Cloud Dn"), GlobalColor("Cloud Up"));
AddCloud(MBUp, UBUp, GlobalColor("Cloud_Up"), GlobalColor("Cloud_Dn"));
AddCloud(MBDn, UBDn, GlobalColor("Cloud_Dn"), GlobalColor("Cloud_Up"));
@High_Velocity
 
Last edited by a moderator:
I add four band colors to Keltner Channel Indicator to show uptrends and downtrends.
Ruby:
# Partial code is from ThinkorSwim
# Modified by Peter luis

declare weak_volume_dependency;

input displace = 0;
input factor = 1.5;
input length = 20;
input price = close;
input fill =yes;
input averageType = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);

def average = MovingAverage(averageType, price, length);

plot Midline = average[-displace];
Midline.SetDefaultColor(GetColor(1));

plot UpperBand = average[-displace] + shift[-displace];
UpperBand.SetDefaultColor(GetColor(8));

plot LowerBand = average[-displace] - shift[-displace];
LowerBand.SetDefaultColor(GetColor(5));

def a = (UpperBand > UpperBand[1] and Midline > Midline[1]);
def b = (UpperBand < UpperBand[1] and LowerBand < LowerBand[1]);
def c = (UpperBand > UpperBand[1] and Midline > Midline[1]);
def d = (UpperBand < UpperBand[1] and midline < midline[1]);
def e = average(close)>midline;
def f = midline<average(close);
def nan      =   Double.NaN;
def Chg      =   If(a, 1, If(b, -1, 0));
def Hold     =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def Chg_a    =   If((c or e), 1, If((d or f), -1, 0));
def Hold_a   =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def LBUp     =   if fill and Hold[0] == 1 then lowerBand else nan;
def UBUp     =   if fill and Hold[0] == 1 then upperband else nan;
def LBDn     =   if fill and Hold[0] == -1 then lowerband else nan;
def UBDn     =   if fill and Hold[0] == -1 then upperband else nan;
def MBUP     =   if fill and Hold[0] == 1 then midline else nan;
def MBDn     =   if fill and Hold[0] == -1 then Midline else nan;

DefineGlobalColor("Cloud Up", Color.red);
DefineGlobalColor("Cloud_Up", Color.yellow);
DefineGlobalColor("Cloud_Dn", Color.cyan);
DefineGlobalColor("Cloud Dn", Color.green);
AddCloud(LBUp, UBUp, GlobalColor("Cloud Up"), GlobalColor("Cloud Dn"));
AddCloud(LBDn, UBDn, GlobalColor("Cloud Dn"), GlobalColor("Cloud Up"));
AddCloud(MBUp, UBUp, GlobalColor("Cloud_Up"), GlobalColor("Cloud_Dn"));
AddCloud(MBDn, UBDn, GlobalColor("Cloud_Dn"), GlobalColor("Cloud_Up"));
@High_Velocity
Thanks Petergluis!
Two questions: 1- is the Keltner based on ema not simple moving average? 2- Can change colors to 2 colors only, cyan when macd line goes over +0.3 and color change to magenta when macd line goes under -0.3? Thanks again.
 

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
517 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