# Three week closing percentage change

#### CharlieK

##### New member
I want a label on my chart to tell me the percentage difference in closing price, from the highest close to the lowest close, over the last 3 weeks. Just the closing price, not the highs and the lows. How do I reference the close? I have nearly the same thing, for the percentage change between the highest and lowest price of the past 5 daily bars, and trying to convert it, I'm missing something.

What I have is...

input aggregationPeriod = AggregationPeriod.WEEK;
input price_type = close;
input count = 3;
def l = low(period = aggregationperiod.week);
def h = high(period = aggregationperiod.week);
def ThreeWeekHigh = highest(h,count);
def ThreeWeekLow = lowest(l,count);
def ThreeWeekVol = (ThreeWeekHigh-ThreeWeekLow)/ThreeWeekLow*100;
AddLabel(1,"3 Week Vol: " + Round(ThreeWeekVol,2), Color.ORANGE);

I'm getting the High and Low of the last 3 weeks... Not the highest and lowest close. What am I doing wrong? Or... How much of this is just plain wrong!?

Thanks,
Charlie

Thought maybe... But no!

input aggregationPeriod = AggregationPeriod.WEEK;
input price_type = close;
input length = 3;

def l = Lowest(close,3);
def h = Highest(close,3);
def ThreeWeekHigh = Highest(h,length);
def ThreeWeekLow = Lowest(l,length);
def ThreeWeekVol = (ThreeWeekHigh-ThreeWeekLow)/ThreeWeekLow*100;
AddLabel(1,"3 Week Vol: " + Round(ThreeWeekVol,2), Color.ORANGE);

Solution
Got it... Looks like some of it should be redundant, but... it works.

input price_type = close;
input length = 3;

def price = close;
def agg = AggregationPeriod.WEEK;
def L = Lowest(close,length);
def H = Highest(close,length);
def ThreeWeekLow = L;
def ThreeWeekHigh = H;
def ThreeWeekVol = (ThreeWeekHigh-ThreeWeekLow)/ThreeWeekLow*100;
AddLabel(yes,"3 Week Vol: " + Round(ThreeWeekVol,2), Color.ORANGE);
Got it... Looks like some of it should be redundant, but... it works.

input price_type = close;
input length = 3;

def price = close;
def agg = AggregationPeriod.WEEK;
def L = Lowest(close,length);
def H = Highest(close,length);
def ThreeWeekLow = L;
def ThreeWeekHigh = H;
def ThreeWeekVol = (ThreeWeekHigh-ThreeWeekLow)/ThreeWeekLow*100;
AddLabel(yes,"3 Week Vol: " + Round(ThreeWeekVol,2), Color.ORANGE);

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