TTM Candles to Paint First Candle Only

offbeatoperator

New member
Hey everyone! I've been trying to convert this TTM candle code
https://usethinkscript.com/threads/squeeze-watchlist-column-histrogram-colors-for-thinkorswim.9726/
to paint the first candle only without any luck. Any help would be greatly appreciated! FYI I did change some colors, for instance, I changed the cyan bars to green.

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeHistogram = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;
plot hist = if squeezeHistogram>= 0 then
if squeezeHistogram> squeezeHistogram[1] then 2 else 1
else if squeezeHistogram < squeezeHistogram[1] then -2 else -1;
assignPriceColor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.GREEN else color.CYAN
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.YELLOW);
hist.assignvaluecolor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.GREEN else color.CYAN
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.YELLOW);
 
Last edited by a moderator:
Solution
Hey everyone! I've been trying to convert this TTM candle code to paint the first candle only without any luck. Any help would be greatly appreciated! FYI I did change some colors, for instance, I changed the cyan bars to green.

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeHistogram = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;
plot hist = if squeezeHistogram>= 0 then
if squeezeHistogram> squeezeHistogram[1] then 2 else 1
else if squeezeHistogram < squeezeHistogram[1] then -2 else -1;
assignPriceColor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.GREEN else color.CYAN
else if squeezeHistogram < squeezeHistogram[1] then...
Hey everyone! I've been trying to convert this TTM candle code to paint the first candle only without any luck. Any help would be greatly appreciated! FYI I did change some colors, for instance, I changed the cyan bars to green.

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeHistogram = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;
plot hist = if squeezeHistogram>= 0 then
if squeezeHistogram> squeezeHistogram[1] then 2 else 1
else if squeezeHistogram < squeezeHistogram[1] then -2 else -1;
assignPriceColor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.GREEN else color.CYAN
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.YELLOW);
hist.assignvaluecolor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.GREEN else color.CYAN
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.YELLOW);

This seems to work

Snip.png
Ruby:
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeHistogram = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;

plot hist = if squeezeHistogram>= 0 then
if squeezeHistogram> squeezeHistogram[1] then 2 else 1
else if squeezeHistogram < squeezeHistogram[1] then -2 else -1;

assignpriceColor(if hist==2 and hist[1]!=2
                 then color.green
                 else if hist==1 and hist[1]!=1
                 then color.cyan
                 else if hist==-2 and hist[1]!=-2
                 then color.red
                 else if hist==-1 and hist[1]!=-1
                 then color.yellow
                 else color.gray);


hist.assignvaluecolor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.GREEN else color.CYAN
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.YELLOW);
 
Solution

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

Thread starter Similar threads Forum Replies Date
JL356 Show Heikin-Ashi Candles over TTM trend Questions 7
rvaidyamath TTM Squeeze scan not working Questions 2
rvaidyamath TTM with SQz Confirmation Questions 1
J Find slope of TTM Lrc Questions 2
rvaidyamath TTM Help Questions 1

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
404 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