Highest High and Lowest Low of Previous N Days

C4men

Member
I am just looking for two horizontal lines to appear on my 15min timeframe chart:

Line 1 - Finds the highest high of the previous five days (or X days) and plots it on my 15 min chart
Line 2 - Finds the lowest low of the previous five days (or X days) and plots it on my 15 min chart

For whatever reason, it does not seem to work no matter what I try and I am sure it is very simple.
Maybe something to do with a higher timeframe?

Any thoughts?
 
I am just looking for two horizontal lines to appear on my 15min timeframe chart:

Line 1 - Finds the highest high of the previous five days (or X days) and plots it on my 15 min chart
Line 2 - Finds the lowest low of the previous five days (or X days) and plots it on my 15 min chart

For whatever reason, it does not seem to work no matter what I try and I am sure it is very simple.
Maybe something to do with a higher timeframe?

Any thoughts?
post the code you tried
 

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

I am just looking for two horizontal lines to appear on my 15min timeframe chart:

Line 1 - Finds the highest high of the previous five days (or X days) and plots it on my 15 min chart
Line 2 - Finds the lowest low of the previous five days (or X days) and plots it on my 15 min chart

For whatever reason, it does not seem to work no matter what I try and I am sure it is very simple.
Maybe something to do with a higher timeframe?

Any thoughts?

is this what you are thinking of ?

Code:
#hilo_agg_xdays

#https://usethinkscript.com/threads/highest-high-and-lowest-low-of-previous-n-days.17773/
#Highest High and Lowest Low of Previous N Days

def na = Double.NaN;
def bn = BarNumber();

def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);

input agg = AggregationPeriod.DAY;
input days = 5;

def hi = highest(high(period = agg), days);
def lo = lowest(low(period = agg), days);

plot zhi = hi;
plot zlo = lo;


#

C 15min
5 day high and low lines
sWGqY7g.jpg
 
is this what you are thinking of ?

Code:
#hilo_agg_xdays

#https://usethinkscript.com/threads/highest-high-and-lowest-low-of-previous-n-days.17773/
#Highest High and Lowest Low of Previous N Days

def na = Double.NaN;
def bn = BarNumber();

def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);

input agg = AggregationPeriod.DAY;
input days = 5;

def hi = highest(high(period = agg), days);
def lo = lowest(low(period = agg), days);

plot zhi = hi;
plot zlo = lo;


#

C 15min
5 day high and low lines
sWGqY7g.jpg

That's pretty close (and thank you).

The only thing is it looks like it is "counting" the current day high or low. I would always want it to start at "yesterday".
That way the line for today would represent the highest high (or lowest low) of the previous five days
 
That's pretty close (and thank you).

The only thing is it looks like it is "counting" the current day high or low. I would always want it to start at "yesterday".
That way the line for today would represent the highest high (or lowest low) of the previous five days
oops , i missed the previous part

here is another version that has an offset, default set to 1

Code:
#hilo_agg_prev_xdays

#https://usethinkscript.com/threads/highest-high-and-lowest-low-of-previous-n-days.17773/
#Highest High and Lowest Low of Previous N Days

#Line 1 - Finds the highest high of the previous five days (or X days) and plots it on my 15 min chart
#Line 2 - Finds the lowest low of the previous five days (or X days) and plots it on my 15 min chart


def na = Double.NaN;
def bn = BarNumber();

def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);
input bars_offset = 1;

input agg = AggregationPeriod.DAY;
input days = 5;

def hi = highest(high(period = agg)[bars_offset], days);
def lo = lowest(low(period = agg)[bars_offset], days);

plot zhi = hi;
plot zlo = lo;
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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