is it possible to have a label showing highest high / lowest low candle of the last 7 bars?

image.png


something like this put a arrow on top or a label on top that it's highest high of last 7 bars, the arrow will be ideally removed after 7 bars for a recount.
same for lowest low
🙏
 
Solution
image.png


something like this put a arrow on top or a label on top that it's highest high of last 7 bars, the arrow will be ideally removed after 7 bars for a recount.
same for lowest low
🙏
IMO - It's easier to do a label as it will be more difficult to remove the arrows and force you to look forward and backward. This will show a label for the highest highs and lows in the last 'x' bars:

input length = 7;
def HH = Highest(high,length);
def LL = Lowest(low,length);
AddLabel(yes,HH,Color.LIGHT_GREEN);
AddLabel(yes,LL,Color.LIGHT_RED);

Hopefully you can work with that to get exactly what you are looking for...
image.png


something like this put a arrow on top or a label on top that it's highest high of last 7 bars, the arrow will be ideally removed after 7 bars for a recount.
same for lowest low
🙏
IMO - It's easier to do a label as it will be more difficult to remove the arrows and force you to look forward and backward. This will show a label for the highest highs and lows in the last 'x' bars:

input length = 7;
def HH = Highest(high,length);
def LL = Lowest(low,length);
AddLabel(yes,HH,Color.LIGHT_GREEN);
AddLabel(yes,LL,Color.LIGHT_RED);

Hopefully you can work with that to get exactly what you are looking for...
 
Solution

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

something like this put a arrow on top or a label on top that it's highest high of last 7 bars, the arrow will be ideally removed after 7 bars for a recount.
same for lowest low


this will draw arrows on the highest and lowest bars, during the last 7 bars on a chart.
can change the quatity of bars. default is 7.
can draw horizontal lines at those levels.
can show labels of the high and low. (copied from tony code)
if 2+ bars have the same highest (or lowest) price, all will have an arrow.


Code:
# find_highest_of_last_x_bars_01

#https://usethinkscript.com/threads/is-it-possible-to-have-a-label-showing-highest-high-lowest-low-candle-of-the-last-7-bars.13603/
# show highest high / lowest low candle of the last 7 bars?


def na = double.nan;
def bn = barnumber();

input length = 7;
def x1 = (!isnan(close[-(length-1)]) and isnan(close[-(length+0)]));
def x_period = (!isnan(close) and isnan(close[-(length+0)]));

# if x bars till last bar, then look ahead to find the highest and lowest price
def hihi;
def lolo;
if x1 then {
  hihi = highest(high[-(length-1)], length);
  lolo = lowest(low[-(length-1)], length);
} else {
  hihi = hihi[1];
  lolo = lolo[1];
}

# draw arrows
def vert = 0.0005;
plot zhi = if high == hihi then (high*(1+vert)) else na;
zhi.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zhi.SetDefaultColor(Color.cyan);
zhi.setlineweight(2);
zhi.hidebubble();

plot zlo = if low == lolo then (low*(1-vert)) else na;
zlo.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zlo.SetDefaultColor(Color.cyan);
zlo.setlineweight(2);
zlo.hidebubble();

# draw lines
input show_hilo_lines = yes;
plot zhiline = if (show_hilo_lines and x_period) then hihi else na;
zhiline.SetDefaultColor(Color.gray);
zhiline.hidebubble();

plot zloline = if (show_hilo_lines and x_period) then lolo else na;
zloline.SetDefaultColor(Color.gray);
zloline.hidebubble();

input show_labels = yes;
AddLabel(show_labels, hihi, Color.LIGHT_GREEN);
AddLabel(show_labels, lolo, Color.LIGHT_RED);

#input show_vertical_line = no;
# addverticalline(show_vertical_line and x1, "-");
#

cxxwUg4.jpg
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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