#### JJJJJJ11111

##### Member
anyone has indicator to auto plot ADR on the 1m chart for day trader?

using last 20 days Average daily range

it search for any intraday 9.30am to 4pm

1. initial day high is found and say adr is 10% . price high is \$100. it will plot a 10% line below day high. later if price high went higher to \$105, it will adjust the line to be 10% below \$105.
2. inverse the same for using day low and plot a supposingly day high line base on ADR% in daily chart.

I'm thinking if daily ADR% can't mix with 1m chart, maybe an indicator to self input ADR% and let it plot the 2 lines .

I only have the code for ADR% daily
Code:
``````input len = 20;
def ADR_perc = (Average(high/low, len) -1);

thanks in advance for any help!

Solution
@JJJJJJ11111 So, I can up with this based upon your description.
It plots based on previous day data, starting at 0930.
I've added some mid lines as well. If you don't need them, then just remove the plot definitions.
To use the calculated ADR, leave the input 'ADR Percent' at zero.
To use a custom percentage, change the input to whatever you want.

Ruby:
``````def Dhigh = high(period = AggregationPeriod.DAY);
def Dlow = low(period = AggregationPeriod.DAY);

input Initial_High_Low_Time = 0930;
input EOD = 1600;
def RTH = SecondsFromTime(Initial_High_Low_Time) >= 0 and SecondsTillTime(EOD) >=0;
input len = 20;

#### Svanoy

##### Well-known member
@JJJJJJ11111 So, I can up with this based upon your description.
It plots based on previous day data, starting at 0930.
I've added some mid lines as well. If you don't need them, then just remove the plot definitions.
To use the calculated ADR, leave the input 'ADR Percent' at zero.
To use a custom percentage, change the input to whatever you want.

Ruby:
``````def Dhigh = high(period = AggregationPeriod.DAY);
def Dlow = low(period = AggregationPeriod.DAY);

input Initial_High_Low_Time = 0930;
input EOD = 1600;
def RTH = SecondsFromTime(Initial_High_Low_Time) >= 0 and SecondsTillTime(EOD) >=0;
input len = 20;

def Ihigh;
def Ilow;
def Nhigh;
def Nlow;

Ihigh = if SecondsTillTime(Initial_High_Low_Time) == 0 then high else Ihigh[1];
Ilow =  if SecondsTillTime(Initial_High_Low_Time) == 0 then low else Ilow[1];

Nhigh = if SecondsTillTime(Initial_High_Low_Time) == 0 then ADRhigh else if high >= Nhigh[1]+(Nhigh[1]*(ADR_perc/100)) then high-(high*(ADR_perc/100)) else CompoundValue(1,Nhigh[1],double.nan);
Nlow = if SecondsTillTime(Initial_High_Low_Time) == 0 then ADRlow else if low <= Nlow[1]-(Nlow[1]*(ADR_perc/100)) then low+(low*(ADR_perc/100)) else CompoundValue(1,Nlow[1],double.nan);

#### JJJJJJ11111

##### Member
thank you it's very comprehensive.
the lines doesn't seem to work as what i explained.

the high red and low green lines, were plotted by the code as potential reversal point.

i had manually measured the 2 plots suppose to be at the 2 yellow lines about 7.3% off the high and off the low

GME works out pretty well stopping around 7.3%

the plot suppose to be the 2 yellow lines when it move out of a range.
and the 2 yellow lines on 3 oct when it is not moving out of a range.

Last edited by a moderator:

#### Svanoy

##### Well-known member
@JJJJJJ11111 Changes to code below.
Ruby:
``````def Dhigh = high(period = AggregationPeriod.DAY);
def Dlow = low(period = AggregationPeriod.DAY);

input Number_of_Days_Shown = 3;
def ShowDay = if GetDay() >= GetLastDay()-Number_of_Days_Shown then 1 else 0;

input Initial_High_Low_Time = 0930;
input EOD = 1600;
def RTH = SecondsFromTime(Initial_High_Low_Time) >= 0 and SecondsTillTime(EOD) >=0;
input len = 20;

def Ihigh;
def Ilow;
def Nhigh;
def Nlow;

Ihigh = if SecondsTillTime(Initial_High_Low_Time) == 0 then high else if high > Ihigh[1] then high else Ihigh[1];
Ilow =  if SecondsTillTime(Initial_High_Low_Time) == 0 then low else if low < Ilow[1] then low else Ilow[1];

Nhigh = if SecondsTillTime(Initial_High_Low_Time) == 0 then ADRhigh else if high > Ihigh[1] then ADRhigh else CompoundValue(1,Nhigh[1],double.nan);

Nlow = if SecondsTillTime(Initial_High_Low_Time) == 0 then ADRlow else if low < Ilow[1] then ADRlow else CompoundValue(1,Nlow[1],double.nan);

plot ADRHP = if ShowDay then Nhigh else double.nan;
plot ADRLP = if ShowDay then Nlow else double.nan;

Just be aware this will cause one of the plots to change dynamically throughout the day depending on price movement.

Last edited by a moderator:

#### JJJJJJ11111

##### Member
thank u .
I try to use this code to show only today , but it's not working.
anyway to let it show only last 3 days.
& exclude extended hours. showing only intraday 9.30am to 4pm

Code:
``````input ShowTodayOnly = yes;

def Today = if GetDay() == GetLastDay() then 1 else 0;``````

Last edited:

#### Svanoy

##### Well-known member
@JJJJJJ11111 updated code above with input to enter how many days to show.

thank u

## 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?