Average of Daily Range

j11235813

New member
Looking for a watch list column that shows the average daily range; the average of the daily range. Not the average true range. Thanks.
 
Solution
Did you find a proper solution? I am in search of the same thing. I need to know if on a given day the price is near the bottom or the top of the price range for let say last week, or 10 days.

The following uses the Daily Highs/Lows to determine the Average Daily Range.

Screenshot-2023-02-23-155158.png
Code:
#ADR_AverageDailyRange_Labels

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

def h = high(period = agg);
def l = low(period = agg);
def top = Sum(h[1], length) / length;
def bot = Sum(l[1], length) / length;
def ADR = top - bot;
def where = if AbsValue(close - top) < AbsValue(close - bot) then 1 else 0;

AddLabel(1, "ADR (" + length + ")  [ATTACH=full]4059[/ATTACH]" + AsDollars(ADR), Color.WHITE);
AddLabel(1, "Today| H: " + AsDollars(h) + " L: " +...
You may need to be more specific, but assuming the high to low range, it would just be Average(high - low, 10) where you could change 10 to what ever length you'd like.
 

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

Looking for a watch list column that shows the average daily range; the average of the daily range. Not the average true range. Thanks.
Did you find a proper solution? I am in search of the same thing. I need to know if on a given day the price is near the bottom or the top of the price range for let say last week, or 10 days.
 
Did you find a proper solution? I am in search of the same thing. I need to know if on a given day the price is near the bottom or the top of the price range for let say last week, or 10 days.

The following uses the Daily Highs/Lows to determine the Average Daily Range.

Screenshot-2023-02-23-155158.png
Code:
#ADR_AverageDailyRange_Labels

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

def h = high(period = agg);
def l = low(period = agg);
def top = Sum(h[1], length) / length;
def bot = Sum(l[1], length) / length;
def ADR = top - bot;
def where = if AbsValue(close - top) < AbsValue(close - bot) then 1 else 0;

AddLabel(1, "ADR (" + length + ")  [ATTACH=full]4059[/ATTACH]" + AsDollars(ADR), Color.WHITE);
AddLabel(1, "Today| H: " + AsDollars(h) + " L: " + AsDollars(l) + " DR: " + AsDollars(h - l), Color.YELLOW);
AddLabel(1, "Today Close (" + AsDollars(close) + ") near: " + (if where == 1 then "TOP " + AsDollars(top) else "BOT " + AsDollars(bot)), if where == 1 then Color.GREEN else Color.RED);
;
 
Solution
I found this https://tos.mx/Qimvmh. Shows today's range and the ATR. You can change the length of the ATR.

And this. https://usethinkscript.com/threads/previous-day-high-low-close-for-thinkorswim.3494/. You need to use the time axis expansion area. Time look is adjustable to the standard time frames. Appears to print on lower time frames.
The previous_day_hig_low_close I have and altered it a bit to end up with this. Let me know if you find it helpful or if you see any mistakes in the logic.

input aggregationPeriod = AggregationPeriod.DAY;
input DaysToUseInCalculation = 4;


def DailyHigh = Highest(high(period = aggregationPeriod), DaysToUseInCalculation);
def DailyLow = Lowest(low(period = aggregationPeriod), DaysToUseInCalculation);

def ADR_high = (dailyHigh[1] + dailyHigh[2] + dailyHigh[3] + dailyHigh[4]) / 4;
def ADR_low = (dailyLow[1] + dailyLow[2] + dailyLow[3] + dailyLow[4]) / 4;

plot ADR_H = ADR_high;
plot ADR_L = ADR_low;

ADR_H.SetDefaultColor(GetColor(6));
ADR_H.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ADR_L.SetDefaultColor(GetColor(4));
ADR_L.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited:
The following uses the Daily Highs/Lows to determine the Average Daily Range.
Since I am looking for a plotted study, not just a lable.... do you find the following code logical?

input aggregationPeriod = AggregationPeriod.DAY;
input DaysToUseInCalculation = 4;


def DailyHigh = Highest(high(period = aggregationPeriod), DaysToUseInCalculation);
def DailyLow = Lowest(low(period = aggregationPeriod), DaysToUseInCalculation);

def ADR_high = (dailyHigh[1] + dailyHigh[2] + dailyHigh[3] + dailyHigh[4]) / 4;
def ADR_low = (dailyLow[1] + dailyLow[2] + dailyLow[3] + dailyLow[4]) / 4;

plot ADR_H = ADR_high;
plot ADR_L = ADR_low;

ADR_H.SetDefaultColor(GetColor(6));
ADR_H.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ADR_L.SetDefaultColor(GetColor(4));
ADR_L.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited:

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