• Get $40 off VIP by signing up for a free account! Sign Up

Prior high and low & 50% of the previous candle as labels?


New member
Hi all,

I am Looking to see if someone can please write a code for the prior high and low and the 50% level of the previous candle to be put in a tab in the upper left corner of the chart that can be colored.

The first column should be the High of the previous candle, the middle column should be the 50% of the previous candle and the third column should be the previous candles low.

Here is a link to a picture of what I am looking for:


Thank you for any help on this..
Last edited by a moderator:
@jr2146 This should plot the labels you want -
@FicoJordan Like this . . . I think. I usually don't use coded alerts so have no idea if this one will work.
plot line = if !isnan(close) and isnan(close[-1]) then hl2[1] else double.nan;

Alert(close crosses line, "HL2 Cross", alert.bar, sound.ring);
@Pensar This is great, any way to make this MTF as well?

input agg = AggregationPeriod.FIFTEEN_MIN ;
def high= high(period = agg);
def low= low(period = agg);
def hl2= hl2(period = agg);


We've noticed that your recent posts have been focused on creating or using MTF indicators. We wanted to offer a suggestion that could potentially save you some time. Have you considered creating your own MTF indicator? This could also be a faster and easier option.
Give it a try, on your next request. Here is the tutorial:
As I was waiting I did a little more digging and created this. I am basing this off the four hour timeframe. This is what I have come up with so far.
The only thing I can't figure out now is how to extend the lines from the previous candle.

input period = AggregationPeriod.FOUR_HOURS;
input symbol = "/es";
input ShowTodayOnly = no;
def today = ShowTodayOnly and GetDay()!=GetLastDay();
def na = Double.NaN; # non-numeric values
def h = high(period = period);
def l = low(period = period);
def c = close(period = period);
input price = close;
input ExtendLines = no;
def ExtLines = if !ExtendLines then IsNaN(close) else
if ExtendLines then 0 else ExtLines[1];

plot MedianPrice = hl2(symbol, period);

plot PrevMedianPrice = if hl2 == 0 or ExtLines or today then na else hl2[-1] ;
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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