Previous Candle High/Low Labels & Bubbles For ThinkOrSwim

Wiinii

Member
Previous Candle High/Low Labels & Bubbles ALL IN ONE - with custom color/transparency global options!

Hello all! I made this for myself and thought others might enjoy it as well. It includes options to turn any label or bubble on and off, and change custom colors and transparency (under Globals). Enjoy!

V0apZCA.png


CqBePZb.png


Code:
#Previous Candle High/Low Labels & Bubbles ALL IN ONE
#By Wiinii: https://usethinkscript.com/threads/previous-candle-high-low-labels-bubbles-for-thinkorswim.10422/
#(change color/transparency under Globals)

#Previous Candle High/Low Labels
Input ShowPreviousCandleHighLabel = yes;
Input ShowPreviousCandleLowLabel = yes;
DefineGlobalColor("PCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Label", Color.PINK);
AddLabel(ShowPreviousCandleLowLabel, Concat ("PCL=", Round(low[1])), GlobalColor("PCL_Label"));
AddLabel(ShowPreviousCandleHighLabel, Concat ("PCH=", Round(high[1])), GlobalColor("PCH_Label"));

#Current Candle High/Low Labels
Input ShowCurrentCandleHighLabel = yes;
Input ShowCurrentCandleLowLabel = yes;
DefineGlobalColor("CCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("CCL_Label", Color.PINK);
AddLabel(ShowCurrentCandleHighLabel, Concat ("CCL=", Round(low)), GlobalColor("CCL_Label"));
AddLabel(ShowCurrentCandleLowLabel, Concat ("CCH=", Round(high)), GlobalColor("CCH_Label"));

#Previous Candle High/Low Bubbles
Input ShowPreviousCandleHighBubble = yes;
Input ShowPreviousCandleLowBubble = yes;
input bubblemoversideways = -2;
def b  = bubblemoversideways;
def b1 = b + 1;
input bubblemoverupdown   = 3;
DefineGlobalColor("PCH_Bubble", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Bubble", Color.PINK);
Addchartbubble(ShowPreviousCandleHighBubble and !isnan(close[b1]) and isnan(close[b]), high[b1+1], "" +round(high[b1+1]) + "", GlobalColor("PCH_Bubble"));
Addchartbubble(ShowPreviousCandleLowBubble and !isnan(close[b1]) and isnan(close[b]), low[b1+1], "" +round(low[b1+1]) + "", GlobalColor("PCL_Bubble"));
 
Last edited:

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

How hard would it be to have a label showing an average candle range say the last 5 or 10 or 15 candles? I was thinking about using set label to figure out an average possible StopLoss with that so If an average range is $1 I dont put 25 cent SL...... would be a great start????
 
How hard would it be to have a label showing an average candle range say the last 5 or 10 or 15 candles? I was thinking about using set label to figure out an average possible StopLoss with that so If an average range is $1 I dont put 25 cent SL...... would be a great start????

try this

Code:
input avg_len = 10;
def rng = high - low;
def rngavg = average(rng, avg_len);
addlabel(1, "range avg, for past " + avg_len + " bars :"  + rngavg, color.yellow);
 
try this

Code:
input avg_len = 10;
def rng = high - low;
def rngavg = average(rng, avg_len);
addlabel(1, "range avg, for past " + avg_len + " bars :"  + rngavg, color.yellow);
Thank you soooooooooooooooooooooooooooo much!!! wow...that was fast and exactly what I was looking for.....
 
How hard would it be to have a label showing an average candle range say the last 5 or 10 or 15 candles? I was thinking about using set label to figure out an average possible StopLoss with that so If an average range is $1 I dont put 25 cent SL...... would be a great start????
I actually made one for myself a while back and use it, it's basically ATR on chart for any timeframe and you can choose the ATR period. So you could choose for example Period: 1Min and ATR period: 5 for last 5 candles.:
3SGOitU.png

Code:
#Multi-option ATR on chart
#By Wiinii: https://usethinkscript.com/threads/previous-candle-high-low-labels-bubbles-for-thinkorswim.10422/post-104574
input ATRPeriod = 14;
input Period = AggregationPeriod.day;
def ATR = MovingAverage(AverageType.WILDERS, TrueRange(high(period = period), close(period = period), low(period = period)), ATRperiod);
DefineGlobalColor("ATR", Color.WHITE);
AddLabel(yes, "ATR" + ATRPeriod + ": " + round(ATR,2), GlobalColor("ATR"));
 
Last edited:
Previous Candle High/Low Labels & Bubbles ALL IN ONE - with custom color/transparency global options!

Hello all! I made this for myself and thought others might enjoy it as well. It includes options to turn any label or bubble on and off, and change custom colors and transparency (under Globals). Enjoy!

V0apZCA.png


CqBePZb.png


Code:
#Previous Candle High/Low Labels & Bubbles ALL IN ONE
#By Wiinii: https://usethinkscript.com/threads/previous-candle-high-low-labels-bubbles-for-thinkorswim.10422/
#(change color/transparency under Globals)

#Previous Candle High/Low Labels
Input ShowPreviousCandleHighLabel = yes;
Input ShowPreviousCandleLowLabel = yes;
DefineGlobalColor("PCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Label", Color.PINK);
AddLabel(ShowPreviousCandleLowLabel, Concat ("PCL=", Round(low[1])), GlobalColor("PCL_Label"));
AddLabel(ShowPreviousCandleHighLabel, Concat ("PCH=", Round(high[1])), GlobalColor("PCH_Label"));

#Current Candle High/Low Labels
Input ShowCurrentCandleHighLabel = yes;
Input ShowCurrentCandleLowLabel = yes;
DefineGlobalColor("CCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("CCL_Label", Color.PINK);
AddLabel(ShowCurrentCandleHighLabel, Concat ("CCL=", Round(low)), GlobalColor("CCL_Label"));
AddLabel(ShowCurrentCandleLowLabel, Concat ("CCH=", Round(high)), GlobalColor("CCH_Label"));

#Previous Candle High/Low Bubbles
Input ShowPreviousCandleHighBubble = yes;
Input ShowPreviousCandleLowBubble = yes;
input bubblemoversideways = -2;
def b  = bubblemoversideways;
def b1 = b + 1;
input bubblemoverupdown   = 3;
DefineGlobalColor("PCH_Bubble", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Bubble", Color.PINK);
Addchartbubble(ShowPreviousCandleHighBubble and !isnan(close[b1]) and isnan(close[b]), high[b1+1], "" +round(high[b1+1]) + "", GlobalColor("PCH_Bubble"));
Addchartbubble(ShowPreviousCandleLowBubble and !isnan(close[b1]) and isnan(close[b]), low[b1+1], "" +round(low[b1+1]) + "", GlobalColor("PCL_Bubble"));
Wiinii, great job and thank you so much for sharing this. Hate to ask but would it be possible to have the labels (and bubbles?) change color as current price goes above or below the prior price? Example: the CCH label would change from light green to dark if current price goes above the prior candle's high and for the CCL a darker shade of red as current price goes below prior candle's low.
 
This might be what you want.
@SleepyZ can you help me do the same thing with this? I tried changing the bubble script like you did with the zigzag above but it just takes out both the prior high price and bubble. All I want is the price. Oh and have not received a reply back from Wiinii and that's why I am asking you. Thanks

#Previous Candle High/Low Labels & Bubbles ALL IN ONE
#By Wiinii: https://usethinkscript.com/threads/previous-candle-high-low-labels-bubbles-for-thinkorswim.10422/
#(change color/transparency under Globals)

#Previous Candle High/Low Labels
Input ShowPreviousCandleHighLabel = yes;
Input ShowPreviousCandleLowLabel = yes;
DefineGlobalColor("PCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Label", Color.PINK);
AddLabel(ShowPreviousCandleLowLabel, Concat ("PCL=", Round(low[1])), GlobalColor("PCL_Label"));
AddLabel(ShowPreviousCandleHighLabel, Concat ("PCH=", Round(high[1])), GlobalColor("PCH_Label"));

#Current Candle High/Low Labels
Input ShowCurrentCandleHighLabel = yes;
Input ShowCurrentCandleLowLabel = yes;
DefineGlobalColor("CCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("CCL_Label", Color.PINK);
AddLabel(ShowCurrentCandleHighLabel, Concat ("CCL=", Round(low)), GlobalColor("CCL_Label"));
AddLabel(ShowCurrentCandleLowLabel, Concat ("CCH=", Round(high)), GlobalColor("CCH_Label"));

#Previous Candle High/Low Bubbles
Input ShowPreviousCandleHighBubble = yes;
Input ShowPreviousCandleLowBubble = yes;
input bubblemoversideways = -2;
def b = bubblemoversideways;
def b1 = b + 1;
input bubblemoverupdown = 3;
DefineGlobalColor("PCH_Bubble", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Bubble", Color.PINK);
Addchartbubble(ShowPreviousCandleHighBubble and !isnan(close[b1]) and isnan(close), high[b1+1], "" +round(high[b1+1]) + "", GlobalColor("PCH_Bubble"));
Addchartbubble(ShowPreviousCandleLowBubble and !isnan(close[b1]) and isnan(close), low[b1+1], "" +round(low[b1+1]) + "", GlobalColor("PCL_Bubble"));
 
Last edited by a moderator:
Previous Candle High/Low Labels & Bubbles ALL IN ONE - with custom color/transparency global options!

Hello all! I made this for myself and thought others might enjoy it as well. It includes options to turn any label or bubble on and off, and change custom colors and transparency (under Globals). Enjoy!

V0apZCA.png


CqBePZb.png


Code:
#Previous Candle High/Low Labels & Bubbles ALL IN ONE
#By Wiinii: https://usethinkscript.com/threads/previous-candle-high-low-labels-bubbles-for-thinkorswim.10422/
#(change color/transparency under Globals)

#Previous Candle High/Low Labels
Input ShowPreviousCandleHighLabel = yes;
Input ShowPreviousCandleLowLabel = yes;
DefineGlobalColor("PCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Label", Color.PINK);
AddLabel(ShowPreviousCandleLowLabel, Concat ("PCL=", Round(low[1])), GlobalColor("PCL_Label"));
AddLabel(ShowPreviousCandleHighLabel, Concat ("PCH=", Round(high[1])), GlobalColor("PCH_Label"));

#Current Candle High/Low Labels
Input ShowCurrentCandleHighLabel = yes;
Input ShowCurrentCandleLowLabel = yes;
DefineGlobalColor("CCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("CCL_Label", Color.PINK);
AddLabel(ShowCurrentCandleHighLabel, Concat ("CCL=", Round(low)), GlobalColor("CCL_Label"));
AddLabel(ShowCurrentCandleLowLabel, Concat ("CCH=", Round(high)), GlobalColor("CCH_Label"));

#Previous Candle High/Low Bubbles
Input ShowPreviousCandleHighBubble = yes;
Input ShowPreviousCandleLowBubble = yes;
input bubblemoversideways = -2;
def b  = bubblemoversideways;
def b1 = b + 1;
input bubblemoverupdown   = 3;
DefineGlobalColor("PCH_Bubble", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Bubble", Color.PINK);
Addchartbubble(ShowPreviousCandleHighBubble and !isnan(close[b1]) and isnan(close[b]), high[b1+1], "" +round(high[b1+1]) + "", GlobalColor("PCH_Bubble"));
Addchartbubble(ShowPreviousCandleLowBubble and !isnan(close[b1]) and isnan(close[b]), low[b1+1], "" +round(low[b1+1]) + "", GlobalColor("PCL_Bubble"));
ANy way to make the current candle price a bubble?
 
Hello Wiinii is there a way for the bubbles to me placed further by the left side so that the bubbles don´t block the current candle?
 
@samer800 Could you adjust this code for MTF I think it would be great much appreciated

#Previous Candle High/Low Labels & Bubbles ALL IN ONE
#By Wiinii: https://usethinkscript.com/threads/previous-candle-high-low-labels-bubbles-for-thinkorswim.10422/
#(change color/transparency under Globals)

#Previous Candle High/Low Labels
Input ShowPreviousCandleHighLabel = yes;
Input ShowPreviousCandleLowLabel = yes;
DefineGlobalColor("PCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Label", Color.PINK);
AddLabel(ShowPreviousCandleLowLabel, Concat ("PCL=", Round(low[1])), GlobalColor("PCL_Label"));
AddLabel(ShowPreviousCandleHighLabel, Concat ("PCH=", Round(high[1])), GlobalColor("PCH_Label"));

#Current Candle High/Low Labels
Input ShowCurrentCandleHighLabel = yes;
Input ShowCurrentCandleLowLabel = yes;
DefineGlobalColor("CCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("CCL_Label", Color.PINK);
AddLabel(ShowCurrentCandleHighLabel, Concat ("CCL=", Round(low)), GlobalColor("CCL_Label"));
AddLabel(ShowCurrentCandleLowLabel, Concat ("CCH=", Round(high)), GlobalColor("CCH_Label"));

#Previous Candle High/Low Bubbles
Input ShowPreviousCandleHighBubble = yes;
Input ShowPreviousCandleLowBubble = yes;
input bubblemoversideways = -2;
def b = bubblemoversideways;
def b1 = b + 1;
input bubblemoverupdown = 3;
DefineGlobalColor("PCH_Bubble", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Bubble", Color.PINK);
Addchartbubble(ShowPreviousCandleHighBubble and !isnan(close[b1]) and isnan(close), high[b1+1], "" +round(high[b1+1]) + "", GlobalColor("PCH_Bubble"));
Addchartbubble(ShowPreviousCandleLowBubble and !isnan(close[b1]) and isnan(close), low[b1+1], "" +round(low[b1+1]) + "", GlobalColor("PCL_Bubble"));


No, unfortunately, what you are looking for is not possible.

You are saying:
You are on the 2min chart. You want to look back 30 bars to retrieve the previous candle of the 30min chart
but you see, the problem?

Let's say that it is 10:02am, to get find the value of the previous 30min bar (9:30am) on the 2min chart
You would have to look back 16 of the 2min bars.

At 10:04 am, you would have to look back 17 of the 2min bars.

See?

To do what you want you would need to program in every bar on the chart for the entire day and
then calculate the math for every timeframe.
its currently 11:32 AM EST, and I wanted to see the previous high of the 30-minute high and low which is the 11:00 AM high and low and be able to do this on a 1 or 2-minute time frame
 
Last edited by a moderator:
No, unfortunately, what you are looking for is not possible.

You are saying:
You are on the 2min chart. You want to look back 30 bars to retrieve the previous candle of the 30min chart
but you see, the problem?

Let's say that it is 10:02am, to get find the value of the previous 30min bar (9:30am) on the 2min chart
You would have to look back 16 of the 2min bars.

At 10:04 am, you would have to look back 17 of the 2min bars.

See?

To do what you want you would need to program in every bar on the chart for the entire day and
then calculate the math for every timeframe.
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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