• Get $40 off VIP by signing up for a free account! Sign Up

Request for: average ATR range for same bar from different period

astrostrider

New member
Greetings from Europe,
Is it possible to use price information for the same bar in different time periods to construct a moving ATR band? Fore example using a 5-min bar at 9:30-9:35 over the last 20 days to computer ATR for that particular bar, etc. I think it's helpful for intraday trading as it factors in intraday time-period based volatilities. I tried to do it myself but I am not a developer and there is this saying "old dog doesn't learn new tricks". Would appreciate it very much if someone can help. Thanks a lot.
 
Greetings from Europe,
Is it possible to use price information for the same bar in different time periods to construct a moving ATR band? Fore example using a 5-min bar at 9:30-9:35 over the last 20 days to computer ATR for that particular bar, etc. I think it's helpful for intraday trading as it factors in intraday time-period based volatilities. I tried to do it myself but I am not a developer and there is this saying "old dog doesn't learn new tricks". Would appreciate it very much if someone can help. Thanks a lot.

See if this method helps. It uses 'thisday snippet' to capture each day's atr, starting with thisday at 0 for today and the thisday between 1 to 20 for the past 20 days, all at 0935's bar.

Screenshot-2021-08-27-142755.jpg
Ruby:
input lookback = 20;
input time     = 0935;
def ymd        = GetYYYYMMDD();
def candles    = if IsNaN(close) then candles[1] else close;
def capture    = candles and ymd != ymd[1];
def dayCount   = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
def thisDay    = (HighestAll(dayCount) - dayCount) ;
def atrpast    = if Between(thisDay, 1, lookback) and SecondsFromTime(0935) == 0 then atrpast[1] + Average(TrueRange(high, close, low), 1) else atrpast[1];
def atrtoday   = if thisDay == 0 and SecondsFromTime(0935) == 0 then Average(TrueRange(high, close, low), 1) else atrtoday[1];
AddLabel(1, "ATR@" + time + " - Today: " + atrtoday + "; Last " + lookback + " days: " + (atrpast / lookback), if atrtoday > (atrpast / lookback) then Color.LIGHT_GREEN else Color.LIGHT_RED);
 
Thank you SleepyZ. I was able to modify someone's code to get time-segment based ATRs for each bar, but have difficulties to apply to a reference curve. I would like to have it pre-plotted in advance but all MAs are laggard. I am trying to find a price projection curve, which probably render this idea useless.
 

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
409 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