auto plot ADR on chart for day trader.

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);
AddLabel(yes,"ADR: "+AsPercent(ADR_perc),Color.BLUE);

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.

A1CQmHN.png



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;
input ADR_Percent = 0;

def ADR_perc = if ADR_Percent == 0 then (Average(Dhigh/Dlow, len)...

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.

A1CQmHN.png



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;
input ADR_Percent = 0;

def ADR_perc = if ADR_Percent == 0 then (Average(Dhigh/Dlow, len) -1) else ADR_Percent;
AddLabel(yes,"ADR: "+AsPercent(ADR_perc),Color.BLUE);

def Ihigh;
def Ilow;
def ADRhigh;
def ADRlow;
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];

ADRhigh = Ihigh-(Ihigh*(ADR_perc/100));
ADRlow = Ilow+(Ilow*(ADR_perc/100));

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);

def ADRH = if isnan(close) then ADRH[1] else if SecondsTillTime(Initial_High_Low_Time) == 0 then Nhigh[1] else  CompoundValue(1,ADRH[1],double.nan);
def ADRL = if isnan(close) then ADRL[1] else if SecondsTillTime(Initial_High_Low_Time) == 0 then Nlow[1] else CompoundValue(1,ADRL[1],double.nan);

plot ADRHP = ADRH;
ADRHP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot ADRLP = ADRL;
ADRLP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot ADRMID = ADRL+((ADRH-ADRL)/2);
ADRMID.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot ADRHMID = ADRMID+((ADRH-ADRMID)/2);
ADRHMID.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot ADRLMID = ADRL+((ADRMID-ADRL)/2);
ADRLMID.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Solution
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%😅

base on ~7.3% GME's ADR.
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.
image.png
 
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;
input ADR_Percent = 0.00;

def ADR_perc = if ADR_Percent == 0.00 then (Average(Dhigh/Dlow, len) -1) else ADR_Percent/100;

AddLabel(yes,"ADR: "+AsPercent(ADR_perc),Color.BLUE);

def Ihigh;
def Ilow;
def ADRhigh;
def ADRlow;
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];

ADRhigh = Ihigh-(Ihigh*(ADR_perc));
ADRlow = Ilow+(Ilow*(ADR_perc));

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;
ADRHP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot ADRLP = if ShowDay then Nlow else double.nan;
ADRLP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

Just be aware this will cause one of the plots to change dynamically throughout the day depending on price movement.
J6sWTWx.png
 
Last edited by a moderator:
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:

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.
Top