# Candlestick Sentiment Indicator for ThinkorSwim

#### BenTen

Staff member
Staff
VIP
My recent discovery in terms of trading learning materials is "YTC Price Action Trader" book. It contains numerous invaluable clues, which I couldn't find anywhere else. One YTC chapter covers Candle Sentiment analysis. Watching where 'close' of the candle happens can give early hints about future market action. Most of time you get those hints before the indicators provide it.

Close Sentiment: This is single-candle analysis. Divide entire range of a candle (low to high) into 3 equal parts. The candle is:
• "High Close" - if 'close' is in the upper 1/3
• "Mid Close" - if 'close' is in the middle 1/3
• "Low Close" - if 'close' is in the lower 1/3
Close Comparison: Compare position of 'close' with entire range of the previous candle. The candle is:
1. Bull Candle - if 'close' is above 'high' of the previous candle
2. Range Candle - if 'close' is between 'high' and 'low' of the previous candle
3. Bear Candle - if 'close' is below 'low' of the previous candle
What can you do with this? It gives very good and early reversal hints. Mid/ranging signals should be considered "no signals" - in other words: market will continue in the same direction.

### thinkScript Code

Code:
``````# YTC Candlestick Sentiment
# Assembled by BenTen at useThinkScript.com

def highclose = (close - low) >= (2 * (high - low) / 3);
def midclose=(close-low)>((high-low)/3) and (close-low)<(2* (high-low)/3);
def lowclose = (close - low) <= ((high - low) / 3);
def YTCbullcandle = close > high[1];
def YTCrangecandle = close < high[1] and close>low[1];
def YTCbearcandle = close < low[1];

assignPriceColor(if YTCbullcandle then Color.GREEN else if YTCbearcandle then Color.RED else Color.WHITE);``````

#### Attachments

• piIs08j.png
83.5 KB · Views: 202
• sTNEfZn.png
84.5 KB · Views: 211
You may have stumbled onto something here.... on the ROKU chart you seem to get a white candle between polarity changes. Just a clue? Maybe.

@markos Certainly. This is an interesting one. Could be used on the 3m and 5m to predict potential trend changes.

ben - very cool - glad you're bring/porting price based indicators. this one has potential!

Does a nice job on daily chart stop trends and reversal - here is the longer time frame 1Y on SPY

#### Attachments

• Qs1KGZp.png
104.2 KB · Views: 207
Last edited by a moderator:
Here is the revised version.

Ruby:
``````# YTC Candlestick Sentiment
# Assembled by BenTen at useThinkScript.com
# 2019.10.08 - diazlaz - Adding states, thresholds, arrows and color bars.

def highclose = (close - low) >= (2 * (high - low) / 3);
def midclose=(close-low)>((high-low)/3) and (close-low)<(2* (high-low)/3);
def lowclose = (close - low) <= ((high - low) / 3);
def YTCbullcandle = close > high[1];
def YTCrangecandle = close < high[1] and close>low[1];
def YTCbearcandle = close < low[1];

# assignPriceColor(if YTCbullcandle then Color.GREEN else if YTCbearcandle then Color.RED else Color.WHITE);

#INPUTS
input showColorBars = yes;
input showArrows = yes;
input YTCThreshold = 2;

#STATES
def sYTC1 = if YTCbullcandle then 100 else if YTCbearcandle then -100 else sYTC1[1];
def sYTC2 = if Sum(sYTC1, YTCThreshold) >= (YTCThreshold * 100) then 100 else if Sum(sYTC1, YTCThreshold) <= (YTCThreshold * -100) then -100 else sYTC2[1];
def sState = sYTC2;

#ARROWS
def sUP = sState crosses above 0;
def sDown = sState crosses below 0;

plot pUP = if !isNan(sUP) then sUP else Double.NaN;
pUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
pUP.SetDefaultColor(Color.GREEN);
pUP.SetLineWeight(2);
pUP.SetHiding(!showArrows);

plot pDown = if !isNan(sDown) then sDown else Double.NaN;
pDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
pDown.SetDefaultColor(Color.RED);
pDown.SetLineWeight(2);
pDown.SetHiding(!showArrows);

#COLORBARS
def pCB = sState;

AssignPriceColor(
if showColorBars then

if IsNaN(pCB) then Color.DARK_GRAY else
if pCB == 100 then Color.GREEN else
Color.RED

else

Color.CURRENT
);

# End of YTC Candlestick Sentiment``````

Last edited by a moderator:
Beautiful Thanks for Sharing @diazlaz !

Nice using this indicator today would have caught and or confirmed many moves in PANW today.

Thanks @BenTen it's great that you can take an idea from the page of a book and make something with it. @diazlaz great addon for this one!

@Charles Wish I can take credit but I can't. The original developer was the real genius. I just converted his script from TradingView to ThinkorSwim.

Most reversals of a trend occur with a consolidation phase of two or more candles. Since this highlights range bound candles it may highlight those areas of potential reversal. Be careful of trading isolated white candles.

87k+ Posts
702 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?