Confirmation Candles Indicator For ThinkorSwim

#Keltner Channel declare lower; def displace = 0; def factorK = 2.0; def lengthK = 20; def price = close; input averageType = AverageType.SIMPLE; def trueRangeAverageType = AverageType.SIMPLE; def BulgeLengthK = 150; def SqueezeLengthK = 150; def BulgeLengthK2 = 40; def SqueezeLengthK2 = 40; def BulgeLengthPrice = 75; def SqueezeLengthPrice = 75; def BulgeLengthPrice2 = 20; def SqueezeLengthPrice2 = 20; def BulgeLengthCC = 40; def SqueezeLengthCC = 40; def BulgeLengthCC2 = 8; def SqueezeLengthCC2 = 8; def shift = factorK * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengthK); def averageK = MovingAverage(averageType, price, lengthK); def AvgK = averageK[-displace]; def Upper_BandK = averageK[-displace] + shift[-displace]; def Lower_BandK = averageK[-displace] - shift[-displace]; def conditionK1 = price >= Upper_BandK; def conditionK2 = (Upper_BandK[1] < Upper_BandK) and (Lower_BandK[1] < Lower_BandK); def conditionK3D = price < Lower_BandK; def conditionK4D = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK); def conditionK2L = (Upper_BandK[2] < Upper_BandK[1]) and (Lower_BandK[2] < Lower_BandK[1]); def conditionK3L = (Upper_BandK[3] < Upper_BandK[2]) and (Lower_BandK[3] < Lower_BandK[2]); def conditionK3 = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK); def BandwidthK = (Upper_BandK - Lower_BandK) / AvgK * 100; def condition_BWKUP = BandwidthK[1] < BandwidthK; def condition_BWKDOWN = BandwidthK[1] > BandwidthK; def BulgeK = Highest(BandwidthK, BulgeLengthK); def SqueezeK = Lowest(BandwidthK, SqueezeLengthK); def BulgeK2 = Highest(BandwidthK, BulgeLengthK2); def SqueezeK2 = Lowest(BandwidthK, SqueezeLengthK2); #MACD with Price def fastLength = 12; def slowLength = 26; def MACDLength = 9; input MACD_AverageType = {SMA, default EMA}; def MACDLevel = 0.0; def fastEMA = ExpAverage(price, fastLength); def slowEMA = ExpAverage(price, slowLength); def Value; def Avg; switch (MACD_AverageType) { case SMA: Value = Average(price, fastLength) - Average(price, slowLength); Avg = Average(Value, MACDLength); case EMA: Value = fastEMA - slowEMA; Avg = ExpAverage(Value, MACDLength); } def Diff = Value - Avg; def Level = MACDLevel; def condition1 = Value[1] <= Value; def condition1D = Value[1] > Value; #RSI def RSI_length = 14; def RSI_AverageType = AverageType.WILDERS; def RSI_OB = 70; def RSI_OS = 30; def NetChgAvg = MovingAverage(RSI_AverageType, price - price[1], RSI_length); def TotChgAvg = MovingAverage(RSI_AverageType, AbsValue(price - price[1]), RSI_length); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def RSI = 50 * (ChgRatio + 1); def condition2 = (RSI[3] < RSI) is true or (RSI >= 80) is true; def condition2D = (RSI[3] > RSI) is true or (RSI < 20) is true; def conditionOB1 = RSI > RSI_OB; def conditionOS1 = RSI < RSI_OS; #MFI def MFI_Length = 14; def MFIover_Sold = 20; def MFIover_Bought = 80; def movingAvgLength = 1; def MoneyFlowIndex = Average(MoneyFlow(high, close, low, volume, MFI_Length), movingAvgLength); def MFIOverBought = MFIover_Bought; def MFIOverSold = MFIover_Sold; def condition3 = (MoneyFlowIndex[2] < MoneyFlowIndex) is true or (MoneyFlowIndex > 85) is true; def condition3D = (MoneyFlowIndex[2] > MoneyFlowIndex) is true or (MoneyFlowIndex < 20) is true; def conditionOB2 = MoneyFlowIndex > MFIover_Bought; def conditionOS2 = MoneyFlowIndex < MFIover_Sold; #Forecast def na = Double.NaN; def MidLine = 50; def Momentum = MarketForecast().Momentum; def NearT = MarketForecast().NearTerm; def Intermed = MarketForecast().Intermediate; def FOB = 80; def FOS = 20; def upperLine = 110; def condition4 = (Intermed[1] <= Intermed) or (NearT >= MidLine); def condition4D = (Intermed[1] > Intermed) or (NearT < MidLine); def conditionOB3 = Intermed > FOB; def conditionOS3 = Intermed < FOS; def conditionOB4 = NearT > FOB; def conditionOS4 = NearT < FOS; #Change in Price def lengthCIP = 5; def CIP = (price - price[1]); def AvgCIP = ExpAverage(CIP[-displace], lengthCIP); def CIP_UP = AvgCIP > AvgCIP[1]; def CIP_DOWN = AvgCIP < AvgCIP[1]; def condition5 = CIP_UP; def condition5D = CIP_DOWN; #EMA_1 def EMA_length = 12; def AvgExp = ExpAverage(price[-displace], EMA_length); def condition6 = (price >= AvgExp) and (AvgExp[2] <= AvgExp); def condition6D = (price < AvgExp) and (AvgExp[2] > AvgExp); #EMA_2 def EMA_2length = 20; def displace2 = 0; def AvgExp2 = ExpAverage(price[-displace2], EMA_2length); def condition7 = (price >= AvgExp2) and (AvgExp[2] <= AvgExp); def condition7D = (price < AvgExp2) and (AvgExp[2] > AvgExp); #DMI Oscillator def DMI_length = 5;#Typically set to 10 input DMI_averageType = AverageType.WILDERS; def diPlus = DMI(DMI_length, DMI_averageType)."DI+"; def diMinus = DMI(DMI_length, DMI_averageType)."DI-"; def Osc = diPlus - diMinus; def Hist = Osc; def ZeroLine = 0; def condition8 = Osc >= ZeroLine; def condition8D = Osc < ZeroLine; #Trend_Periods def TP_fastLength = 3;#Typically 7 def TP_slowLength = 4;#Typically 15 def Periods = Sign(ExpAverage(close, TP_fastLength) - ExpAverage(close, TP_slowLength)); def condition9 = Periods > 0; def condition9D = Periods < 0; #Polarized Fractal Efficiency def PFE_length = 5;#Typically 10 def smoothingLength = 2.5;#Typically 5 def PFE_diff = close - close[PFE_length - 1]; def val = 100 * Sqrt(Sqr(PFE_diff) + Sqr(PFE_length)) / Sum(Sqrt(1 + Sqr(close - close[1])), PFE_length - 1); def PFE = ExpAverage(if PFE_diff > 0 then val else -val, smoothingLength); def UpperLevel = 50; def LowerLevel = -50; def condition10 = PFE > 0; def condition10D = PFE < 0; def conditionOB5 = PFE > UpperLevel; def conditionOS5 = PFE < LowerLevel; #Bollinger Bands PercentB input BBPB_averageType = AverageType.SIMPLE; def BBPB_length = 20;#Typically 20 def Num_Dev_Dn = -2.0; def Num_Dev_up = 2.0; def BBPB_OB = 100; def BBPB_OS = 0; def upperBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).UpperBand; def lowerBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).LowerBand; def PercentB = (price - lowerBand) / (upperBand - lowerBand) * 100; def HalfLine = 50; def UnitLine = 100; def condition11 = PercentB > HalfLine; def condition11D = PercentB < HalfLine; def conditionOB6 = PercentB > BBPB_OB; def conditionOS6 = PercentB < BBPB_OS; #STARC Bands def ATR_length = 15; def SMA_lengthS = 6; def multiplier_factor = 1.25; def valS = Average(price, SMA_lengthS); def average_true_range = Average(TrueRange(high, close, low), length = ATR_length); def Upper_BandS = valS[-displace] + multiplier_factor * average_true_range[-displace]; def Middle_BandS = valS[-displace]; def Lower_BandS = valS[-displace] - multiplier_factor * average_true_range[-displace]; def condition12 = (Upper_BandS[1] <= Upper_BandS) and (Lower_BandS[1] <= Lower_BandS); def condition12D = (Upper_BandS[1] > Upper_BandS) and (Lower_BandS[1] > Lower_BandS); #Klinger Histogram def Klinger_Length = 13; def KVOsc = KlingerOscillator(Klinger_Length).KVOsc; def KVOH = KVOsc - Average(KVOsc, Klinger_Length); def condition13 = (KVOH > 0); def condition13D = (KVOH < 0); #Projection Oscillator def ProjectionOsc_length = 30;#Typically 10 def MaxBound = HighestWeighted(high, ProjectionOsc_length, LinearRegressionSlope(price = high, length = ProjectionOsc_length)); def MinBound = LowestWeighted(low, ProjectionOsc_length, LinearRegressionSlope(price = low, length = ProjectionOsc_length)); def ProjectionOsc_diff = MaxBound - MinBound; def PROSC = if ProjectionOsc_diff != 0 then 100 * (close - MinBound) / ProjectionOsc_diff else 0; def PROSC_OB = 80; def PROSC_OS = 20; def condition14 = PROSC > 50; def condition14D = PROSC < 50; def conditionOB7 = PROSC > PROSC_OB; def conditionOS7 = PROSC < PROSC_OS; #Trend Confirmation Calculator #Confirmation_Factor range 1-15. input coloredCandlesOn = no; def Confirmation_Factor = 0; #Use for testing conditions individually. Remove # from line below and change Confirmation_Factor to 1. #def Agreement_Level = condition1; def Agreement_LevelOB = 10; def Agreement_LevelOS = -10; def Agreement_Level = condition1 + condition2 + condition3 + condition4 + condition5 + condition6 + condition7 + condition8 + condition9 + condition10 + condition11 + condition12 + condition13 + condition14 + conditionK1 + conditionK2; def Agreement_LevelD = (condition1D + condition2D + condition3D + condition4D + condition5D + condition6D + condition7D + condition8D + condition9D + condition10D + condition11D + condition12D + condition13D + condition14D + conditionK3D + conditionK4D); plot Consensus_Level = Agreement_Level - Agreement_LevelD; def conditionChannel1 = Upper_BandK > price; def conditionChannel2 = Lower_BandK < price; def UP = Consensus_Level >= 0; def DOWN = Consensus_Level < 0; Consensus_Level.AssignValueColor( if Consensus_Level > Consensus_Level[1] and Consensus_Level >= 0 then Color.LIGHT_GREEN else if Consensus_Level < Consensus_Level[1] and Consensus_Level >= 0 then Color.LIGHT_GREEN else if Consensus_Level < Consensus_Level[1] and Consensus_Level < 0 then Color.RED else if Consensus_Level > Consensus_Level[1] and Consensus_Level < 0 then Color.RED else Color.GRAY); def Zero_Line = 0; AddCloud(Consensus_Level, Agreement_LevelOB, Color.LIGHT_RED, Color.CURRENT); AddCloud(Consensus_Level, Agreement_LevelOS, Color.CURRENT, Color.LIGHT_GREEN); plot BulgeCC = Highest(Consensus_Level, BulgeLengthCC); BulgeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); plot SqueezeCC = Lowest(Consensus_Level, SqueezeLengthCC); SqueezeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); plot BulgeCC2 = Highest(Consensus_Level, BulgeLengthCC2); BulgeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); BulgeCC2.SetStyle(Curve.SHORT_DASH); plot SqueezeCC2 = Lowest(Consensus_Level, SqueezeLengthCC2); SqueezeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); SqueezeCC2.SetStyle(Curve.SHORT_DASH);
thank you for these awesome indicators, i was wondering could you tell me how you were able to get your chart layout like that?, also my candles appear very small, do you know how to enlarge them?
 
thank you for these awesome indicators, i was wondering could you tell me how you were able to get your chart layout like that?, also my candles appear very small, do you know how to enlarge them?
Hi ziongotoptions,
Can you post a screenshot so I can see what's going on?
 
@Christopher84 I remember you saying that if the price is above the red cloud in the red cloud, it will eventually come back below the red cloud, what is your reading when the candlestick is half in the cloud (horizontally) and half outside, Was looking at the apple chart and was not sure what to read from this

u1sbia9.png
 
@Christopher84 I remember you saying that if the price is above the red cloud in the red cloud, it will eventually come back below the red cloud, what is your reading when the candlestick is half in the cloud (horizontally) and half outside, Was looking at the apple chart and was not sure what to read from this

u1sbia9.png
Hi @alexsmith3546!
Looks like it still has room for upward movement. If the candle opens above the cloud, price will retrace. You can see where that occurred 2 candles ago. I hope that helps. Happy trading!
 
@Christopher84 - Fantastic work and communication! I am not comfortable with coding yet even pasting. Could I be a pest and ask for the sharable link to the upper and lower latest version? I really do appreciate your insight and this site.

Bill
 
Yep you've got it!
Wondering about the Scanner and watchlist. The results returned seem to be overbought stocks - Red indicator. If they are overbought is it not too late to be going long? Or is the strategy as such, They have momentum to move higher? Sorry if I am missing an earlier thread that describes the strategy.
 
Wondering about the Scanner and watchlist. The results returned seem to be overbought stocks - Red indicator. If they are overbought is it not too late to be going long? Or is the strategy as such, They have momentum to move higher? Sorry if I am missing an earlier thread that describes the strategy.
Another question, do you recommend extended hours ON for best results with C3
 
Wondering about the Scanner and watchlist. The results returned seem to be overbought stocks - Red indicator. If they are overbought is it not too late to be going long? Or is the strategy as such, They have momentum to move higher? Sorry if I am missing an earlier thread that describes the strategy.
Hi @Scottgray0827,
That’s a really good question. It really depends on where the overbought condition is occurring. If price is coming out of a downtrend and pushes through the mean and goes overbought, it’s likely to retrace before continuing upward. However, if price is in an overbought condition and is breaking to new highs, the momentum is likely to continue. It’s nearly impossible to call tops or bottoms of price action consistently. I tend to pay close attention to the Overbought clouds. When I see price open above the cloud, it tells me that price is likely to consolidate or reverse near term. I hope some of that makes sense. Happy trading!
 
Hi @Scottgray0827,
That’s a really good question. It really depends on where the overbought condition is occurring. If price is coming out of a downtrend and pushes through the mean and goes overbought, it’s likely to retrace before continuing upward. However, if price is in an overbought condition and is breaking to new highs, the momentum is likely to continue. It’s nearly impossible to call tops or bottoms of price action consistently. I tend to pay close attention to the Overbought clouds. When I see price open above the cloud, it tells me that price is likely to consolidate or reverse near term. I hope some of that makes sense. Happy trading!
Makes sense, thanks for your detailed response
 
@toMatto, you're very welcome. Here's a trade I took this morning. It shows how well the MACD_BB (I took the dots off) plays with Christopher's indicators. The yellow line is just a markup of my logic for my journal. Since you trade stocks more than I do, I'd be curious to hear any insights you have as you use Christopher's indicators. Thanks in advance :) Best wishes and happy trading!

@Trader Raider i was looking at your version of the MACD_BB and you seem to have a slightly tweaked version which shows the state of the trend on the zero line (red or green). Would you be comfortable sharing your tweaked version of the indicator or mentioning what code updates you made. Thank you.
 
@Trader Raider i was looking at your version of the MACD_BB and you seem to have a slightly tweaked version which shows the state of the trend on the zero line (red or green). Would you be comfortable sharing your tweaked version of the indicator or mentioning what code updates you made. Thank you.
Here is my moded script that I put toghther with few different scripts. It will paint candles also

# TS_MACD_BB
# By Eric Purdy, ThinkScripter LLC
# http://www.thinkscripter.com
# [email protected]
# Last Update 07 Feb 2011

declare lower;

input price = close;
input BBlength = 10;
input BBNum_Dev = 1.0;
input MACDfastLength = 12;
input MACDslowLength = 26;
input MACDLength = 5;

def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength);

plot MACD_Dots = MACD_Data;
plot MACD_Line = MACD_Data;

plot BB_Upper = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).UpperBand;
plot BB_Lower = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).Lowerband;
plot BB_Midline = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).MidLine;

BB_Upper.SetDefaultColor(Color.GRAY);
BB_Lower.SetDefaultColor(Color.GRAY);
BB_Midline.SetDefaultColor(Color.GRAY);
BB_Midline.SetStyle(Curve.SHORT_DASH);

#MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] then color.green else color.red);

MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line >= BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line >= BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line <= BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line <= BB_Lower then Color.DARK_RED else Color.Yellow);
MACD_Dots.SetStyle(Curve.POINTS);
MACD_Dots.SetLineWeight(2);
MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.GREEN

else Color.RED);
MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line > BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line > BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line < BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line < BB_Lower then Color.DARK_RED else Color.gray);

MACD_Dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);

MACD_Dots.SetLineWeight(1);


plot zero = 0;
zero.AssignValueColor(if MACD_Line < 0 then Color.RED else Color.GREEN);
zero.SetLineWeight(2);


AddCloud( bb_Upper, bb_Lower, Color.Gray );

######Add Squeeze Cloud##########


###### Keltner Channels


input displace = 0;

input factor = 1.5;

input length = 20;

input averageType = AverageType.EXPONENTIAL;

input trueRangeAverageType = AverageType.EXPONENTIAL;


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

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

def Avg = average[-displace];

def Upper_Band = average[-displace] + shift[-displace];

def Lower_Band = average[-displace] - shift[-displace];


######## Bollinger Bands

input BBLength2 = 20;

input Num_Dev_Dn = -2.0;

input Num_Dev_up = 2.0;

input bb_averageType = AverageType.SIMPLE;


def sDev = StDev(data = price[-displace], length = BBLength2);


def MidLine = MovingAverage(bb_averageType, data = price[-displace], length = BBLength2);

def LowerBand = MidLine + Num_Dev_Dn * sDev;

def UpperBand = MidLine + Num_Dev_up * sDev;

### end of script


AddCloud(if UpperBand <= Upper_Band and LowerBand >= Lower_Band then BB_Upper else BB_Lower, BB_Lower, Color.white);

input EMA = 20;
input TEMA = 20;
input high_l = 0.1;
input low_l = -0.1;

def THL = If(high != low, high - low, 0.01);
def BullOpen = (high - open) / THL;
def BearOpen = (open - low) / THL;
def BullClose = (close - low) / THL;
def BearClose = (high - close) / THL;
def BullOC = If(close > open, (close - open) / THL, 0);
def BearOC = If(open > close, (open - close) / THL, 0);
def BullReward = (BullOpen + BullClose + BullOC) / 1;
def BearReward = (BearOpen + BearClose + BearOC) / 1;

def BOP = BullReward - BearReward;
def SmoothBOP = ExpAverage(BOP, EMA);
def xPrice = SmoothBOP;
def xEMA1 = ExpAverage(SmoothBOP, TEMA);
def xEMA2 = ExpAverage(xEMA1, TEMA);
def xEMA3 = ExpAverage(xEMA2, TEMA);
def nRes = 3 * xEMA1 - 3 * xEMA2 + xEMA3;

def SmootherBOP = nRes;
def s1 = SmoothBOP;
def s2 = SmootherBOP;
def s3 = SmootherBOP[2];
# ########################################################
DefineGlobalColor("LabelGreen", CreateColor(0,255, 0)) ;
DefineGlobalColor("LabelRed", CreateColor(225, 0, 0)) ;
input paintbar = yes ;

AssignPriceColor(
if !paintbar then Color.CURRENT else
if MACD_Line > BB_Upper then GlobalColor("LabelGreen") else
if MACD_Line < BB_Lower then GlobalColor("LabelRed") else
Color.WHITE);

def bull_cross = MACD_Line crosses above zero;
def bear_cross = MACD_Line crosses below zero;

# Alerts
Alert(bull_cross, "UP arrow alert", Alert.Bar, Sound.Chimes);
Alert(bear_cross, "DOWN arrow alert", Alert.Bar, Sound.Bell);



# End Code TMO
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
332 Online
Create Post

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