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

RuleOneTrading

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

Capture.jpg
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);
 
Solution
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!
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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