# Daily High-Low compared to Last-Hour Daily High-Low

##### New member
I'm trying to get the (High-Low) of the current day, then use that number to divide the High-Low of the last hour. This will give me a relative percentage of the current hour's range vs the range of the day so I can stop seeing stocks that are barely moving relatively to the earlier movements of the day, since the ATR and APTR are terribly useless on a minute chart when scanning for relative current ranges.

The script would essentially be: (But I'm not sure how to define Today as the length since open

#Custom ATR -

input Length = 60;
input CustomATRpercent = 20;
Input Start = 0930;
Input End = 1400;

def Today =
def TodaysLowerBand = Lowest(low[1], Today);
def TodaysUpperBand = Highest(high[1], Today);
def CurrentLowerBand = Lowest(low[1], Length);
def CurrentUpperBand = Highest(high[1], Length);
def CurrentRange = (CurrentUpperBand-CurrentLowerBand);
def TodaysRange = (TodaysUpperBand-TodaysLowerBand);

plot RangeRatio = (CustomATRPercent <= (CurrentRange/TodaysRange));

Solution
I'm trying to get the (High-Low) of the current day, then use that number to divide the High-Low of the last hour. This will give me a relative percentage of the current hour's range vs the range of the day so I can stop seeing stocks that are barely moving relatively to the earlier movements of the day, since the ATR and APTR are terribly useless on a minute chart when scanning for relative current ranges.

The script would essentially be: (But I'm not sure how to define Today as the length since open

#Custom ATR -

input Length = 60;
input CustomATRpercent = 20;
Input Start = 0930;
Input End = 1400;

def Today =
def TodaysLowerBand = Lowest(low[1], Today);
def TodaysUpperBand = Highest(high[1], Today);
def CurrentLowerBand =...
I'm trying to get the (High-Low) of the current day, then use that number to divide the High-Low of the last hour. This will give me a relative percentage of the current hour's range vs the range of the day so I can stop seeing stocks that are barely moving relatively to the earlier movements of the day, since the ATR and APTR are terribly useless on a minute chart when scanning for relative current ranges.

The script would essentially be: (But I'm not sure how to define Today as the length since open

#Custom ATR -

input Length = 60;
input CustomATRpercent = 20;
Input Start = 0930;
Input End = 1400;

def Today =
def TodaysLowerBand = Lowest(low[1], Today);
def TodaysUpperBand = Highest(high[1], Today);
def CurrentLowerBand = Lowest(low[1], Length);
def CurrentUpperBand = Highest(high[1], Length);
def CurrentRange = (CurrentUpperBand-CurrentLowerBand);
def TodaysRange = (TodaysUpperBand-TodaysLowerBand);

plot RangeRatio = (CustomATRPercent <= (CurrentRange/TodaysRange));

The image displays some testing information and the code was moved to the lower panel to see when the plot is 1/0 (true/false).

Ruby:
``````input Length = 60;
input CustomATRpercent = 20;
input Start = 0930;
input End = 1400;

def Today = SecondsFromTime(Start) >= 0 and SecondsFromTime(End) <= 0;

def todaycount = if Today[1] == 0 and Today then 1 else if Today then todaycount[1] + 1 else todaycount[1];

def TodaysLowerBand = if Today[1] == 0 and Today
then low
else if Today
then Min(low, TodaysLowerBand[1])
else TodaysLowerBand[1];
def TodaysUpperBand = if Today[1] == 0 and Today
then high
else if Today
then Max(high, TodaysUpperBand[1])
else TodaysUpperBand[1];
def CurrentLowerBand = Lowest(low[1], Length);
def CurrentUpperBand = Highest(high[1], Length);
def CurrentRange = (CurrentUpperBand - CurrentLowerBand);
def TodaysRange = (TodaysUpperBand - TodaysLowerBand);

plot RangeRatio = (CustomATRpercent/100 <= (CurrentRange / TodaysRange));

#Testing
input test = yes;
addlabel(test and todaycount < 61, "todays count must be greater than or equal to 60");
AddLabel(test, todaycount + " " + TodaysLowerBand + " " + TodaysUpperBand + " " + CurrentLowerBand + " " + CurrentUpperBand + " " + (CurrentRange / TodaysRange) + " " + RangeRatio);``````

The image displays some testing information and the code was moved to the lower panel to see when the plot is 1/0 (true/false).
....wow... I cannot believe that you took time out of your day to help me fix my script AND ALSO write up a whole entire study to let me test what I'm looking for, whereas I usually test it by running the scan and checking each chart manually to see if I like what I see. Thank you sooo much!

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