Jesse.Lau

[JL] n Bars Average True Range

I just want to use 1-hour ATR on a 5-min chart, but I don't want to use the security function to get 1-hour ATR.

I don't know if there is a similar script but I decided to change a little from the original ATR source code.

Just change tr function to n_true_range function:
  • math.max(ta.highest(high,n) - ta.lowest(low,n), math.max(math.abs(ta.highest(high,n) - close), math.abs(ta.lowest(low,n) - close)))


Here is the comparison image from a 5-min chart with the nATR and a 1-hour chart with the original ATR.


遁一子交易入道 jesselau.com/
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?