# Plot only the high from the last 65 most recent days

#### Pensar

##### Expert
VIP
Ruby:
``plot line = highestall(if !isnan(close) and isnan(close[-1]) then highest(high,65) else double.nan);``
The fold function isn't my strong point, so I can't help on where the code you posted needs changing. Never could understand how it worked.

Can you please provide the codes for the lower line?

can you please provide the code for plotting he low from the last 65 most recent days?

### ​

i added some code to the end of my study,
. to draw a line at the lowest low,
. that exists within the most recent x bars ( not days)

if you want days, set chart to days.

Code:
``````# test_highestbn_05e

# find the highest high, in the most rect x bars

def na = Double.NaN;
def bn = BarNumber();
def lastbar = HighestAll(if !IsNaN(close) then bn else na);

input look_back_bars = 65;
# is the current bar within the lookback quantity of bars? true/false
def rng = (lastbar - bn <= look_back_bars);

def hi = fold i = 0 to look_back_bars
with p
do if !rng then 0 else if GetValue(high, (bn - (lastbar - i))) > p then GetValue(high, (bn - (lastbar - i))) else p;

plot hix = HighestAll(hi);
hix.SetDefaultColor(Color.yellow);
hix.SetStyle(Curve.MEDIUM_DASH);

# test code -------------------------
# identify the first bar in the lookback group
def firstbar = (!IsNaN(close[-look_back_bars]) and IsNaN(close[-(look_back_bars + 1)]));
plot f = firstbar;
f.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
f.SetDefaultColor(Color.yellow);
f.setlineweight(4);

input show_barnumber_bubbles = no;
addchartbubble(show_barnumber_bubbles, low * 0.995, bn + "\n" + "x", color.cyan, no);

#addchartbubble(1, high * 1.01, hi, color.cyan, yes);
#

#--------------------------------

# lowest from prev x bars

def lolo = lowestall(if rng then low else na);
plot lox = lolo;
lox.SetDefaultColor(Color.magenta);
lox.SetStyle(Curve.MEDIUM_DASH);
#``````

i added some code to the end of my study,
. to draw a line at the lowest low,
. that exists within the most recent x bars ( not days)

if you want days, set chart to days.

Code:
``````# test_highestbn_05e

# find the highest high, in the most rect x bars

def na = Double.NaN;
def bn = BarNumber();
def lastbar = HighestAll(if !IsNaN(close) then bn else na);

input look_back_bars = 65;
# is the current bar within the lookback quantity of bars? true/false
def rng = (lastbar - bn <= look_back_bars);

def hi = fold i = 0 to look_back_bars
with p
do if !rng then 0 else if GetValue(high, (bn - (lastbar - i))) > p then GetValue(high, (bn - (lastbar - i))) else p;

plot hix = HighestAll(hi);
hix.SetDefaultColor(Color.yellow);
hix.SetStyle(Curve.MEDIUM_DASH);

# test code -------------------------
# identify the first bar in the lookback group
def firstbar = (!IsNaN(close[-look_back_bars]) and IsNaN(close[-(look_back_bars + 1)]));
plot f = firstbar;
f.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
f.SetDefaultColor(Color.yellow);
f.setlineweight(4);

input show_barnumber_bubbles = no;
addchartbubble(show_barnumber_bubbles, low * 0.995, bn + "\n" + "x", color.cyan, no);

#addchartbubble(1, high * 1.01, hi, color.cyan, yes);
#

#--------------------------------

# lowest from prev x bars

def lolo = lowestall(if rng then low else na);
plot lox = lolo;
lox.SetDefaultColor(Color.magenta);
lox.SetStyle(Curve.MEDIUM_DASH);
#``````
Hi halcyonguy, can you kindly show how to set this to day on the char. do I choose 3M,Day?

87k+ Posts
302 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?