Candlestick Sentiment Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
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.

piIs08j.png

sTNEfZn.png


thinkScript Code

Code:
# YTC Candlestick Sentiment
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/5fSgjYoM-YTC-Candlestick-Sentiment/

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);
 

markos

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

diazlaz

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

Qs1KGZp.png
 
Last edited by a moderator:

diazlaz

Well-known member
2019 Donor
VIP
Here is the revised version.

Ruby:
# YTC Candlestick Sentiment
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/5fSgjYoM-YTC-Candlestick-Sentiment/
# 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:

J007RMC

Well-known member
2019 Donor
Nice using this indicator today would have caught and or confirmed many moves in PANW today.
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
@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.
 

horserider

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

jimothy

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

@BenTen and @diazlaz
I added GetTime() < RegularTradingEnd(GetYYYYMMDD()) and GetTime() > RegularTradingStart(GetYYYYMMDD()) to the definitions.

is there any reason after doing that, that adding a SMA 50 will prevent the UP indicator from showing up in instances?

this simple line will make the arrow not appear some times.
plot SMA2_plot = SimpleMovingAvg(close, 50);

complete code is

Code:
# YTC Candlestick Sentiment
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/5fSgjYoM-YTC-Candlestick-Sentiment/
# 2019.10.08 - diazlaz - Adding states, thresholds, arrows and color bars.

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

# 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

plot SMA2_plot = SimpleMovingAvg(close, 50);

with SMA on within the script
Y3gdS8r.png


with SMA off within the script

BXEWrU7.png


looks like having the SMA50 also turns the previous candles red?

edit ok I think the problem is that the original is using either the overnight candle sentiment, or, using my code, it is using the previous days sentiment in conjunction with the first bar of this day, etc.

is there a way to modify this to basically look at every day in isolation? assume you wanted to automate this script to give u a buy signal or sell signal for day trading
 
Last edited:

Kopite_JATT

New member
Actually I made indicator based on similar ideas. Its a bit more sophisticated (but sophisticated not always better). Its also integrated onto price tracker
https://tos.mx/KbSrnye
Found your sentiment candle very interesting using it daily, wanted to understand it better, What does all theses indicators mean eg: <ZrU, V, <-, etc. and most importantly can you code these indicator to appear in a column form in a watchlist showing just the indicators.
Hope you can help.
 

Zlotko

Member
VIP
I would like to understand it better too....What does all theses indicators mean eg: <ZrU, V, <-, etc Thanks
 

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.
Top