ATR By Time Indicator

Get The Average True Range By Time of Day!

This indicator is designed to be used only on TradingView.

TradingView Username:

4.95 USD / month

Or Join My Mailing List for a One Month Free Trial!

What is ATR By Time?

This indicator was inspired by my RVOL By Time indicator.

Instead of calculating the ATR by recent price data, it calculates an ATR value for each candle based on that candle’s time of day.

For example, if you set the Lookback setting on this indicator to 14, then instead of calculating the ATR based on the past 14 candles, it will calculate an ATR value based on the past 14 trading sessions for each candle.

This is extremely useful for day traders in particular as it allows you to gauge the average range of candles during certain times of day instead of only by the most recent price action.

The indicator will draw your stop loss value to the chart based on the following options:

  • Regular ATR
  • ATR By Time
  • Smallest ATR (Whichever is smallest between regular ATR vs. time ATR)
  • Largest ATR (Whichever is largest between regular ATR vs. time ATR)

This allows for tighter stops and larger position sizing during certain times of day for aggressive traders when set to Smallest ATR, or wider stop losses during more volatile periods of the day for conservative traders when set to Largest ATR.

It also draws a regular ATR value (optional) – so this is essentially an enhanced ATR indicator that gives you multiple readings on price volatility.

The script comes in two parts – an oscillator box for drawing the calculated values separate to your chart, and a chart companion script that draws the stop loss values over price action.

The reason why this is a premium script that requires payment to access is because it took a lot of time, research and development in order to create. Charging money gives me a strong incentive to continue this effort for my customers. The other advantage of charging for it is that it retains exclusivity to only a select few dedicated traders who want to enhance their edge.

I currently use this script in my trading process to analyze the forex markets, but I’m also constantly testing and improving it as my knowledge of Pine Script improves. Therefore this is a constant work-in-progress and I am always working on improving it.

If you don’t want to pay for this script then I have plenty of other free scripts that you might be interested in!

How It Works

This script uses a complex formula to calculate ATR values across distant historical bars.

Depending on the timeframe you select it will skip through historical bars to find previous bars from the same time of day. It collects these values then applies the traditional ATR formula to them.

The ATR value is determined by the maximum result of the following three calculations:

  • Current high minus the current low
  • The absolute value of the current high minus the previous close
  • The absolute value of the current low minus the previous close

Whichever of these three calculations comes out highest, that is your ATR for the given candle.

Once this value is calculated for historical bars, the ATR indicator’s reading is typically determined by a 14-period moving average of these individual ATR values. So the ATR reading you see on your screen is an average of the past 14 ATR values.

This means that as markets expand and contract this volatility reading will adapt to the change in candle price ranges.

The difference with the ATR By Time indicator’s calculation formula is that rather than referencing recent bars, it references bars based on their time of day.

For example, if you are on the 1-Hour chart and you check the ATR By Time value at 9:00AM with a Lookback period of 14, then the value you see will be the average of the ATR calculation of every 9:00AM 1-Hour candle over the past 14 trading sessions.

The gray candle in the background represents the average of the past X amount of trading sessions, whereas the colored part represents the ATR value of the current candle in relation to that.

You can also choose to enable the ATR moving average in the settings menu if you wish. This will give you a smoothed ATR reading by averaging the current session’s ATR value with previous sessions.

This versatility gives you a sophisticated reading on price volatility which is particularly helpful for day trade setups based around market opens or market closes when volatility tends to spike.

The regular ATR indicator will not account for this on the lower timeframes, but this indicator will!


ATR By Time Settings

You can choose from Forex, Crypto, Stocks and Futures. This setting is important – if you choose the wrong one the indicator will be inaccurate. This is because stocks have a different session length to forex, and forex has a different session length to crypto etc., which results in different price gaps that the script needs to account for.

Lookback Period:
This sets how many sessions the indicator will look back. For example, if you set this to 1, then it will show you today’s ATR relative to yesterday’s ATR.

Alert At ATR %:
This will enable alerts based on relative volatility. You can see this reading on the indicator, it is the very last numerical value in blue. Once you set this value, you need to create a new alert by pressing the + button on the alerts widget in the TradingView interface.

When the current candle’s ATR value exceeds the range % of the previous session’s value, the alert will be triggered. For example, if you set this value to 2 and the next candle is twice as large as its previous session’s counterpart, the alert will trigger.

Color Scheme:
This changes the color scheme of the indicator based on different interpretations of the ATR reading.


  • This color if range percent >= 0.25%
  • This color if range percent >= 0.50%
  • This color if range percent >= 0.75%
  • This color if range percent >= 1.00%
  • This color if range percent >= 2.00%


  • This color if range percent >= 0.50%
  • This color if range percent >= 0.75%
  • This color if range percent >= 1.00%
  • This color if range percent >= 2.00%


  • This color if candle closed bullish
  • This color if candle closed bearish


  • This color if range percent >= specified range

RMA Length:
This sets the RMA length for averaging the session averages. Typically I prefer to keep this turned off, but if you want to experiment with “smoothing” the session averages, then that is what this feature is for.

Use RMA On Session Average Line?
If set to true, this will apply the RMA to the purple average line but not the bars, which will give you the best of both worlds. You get to see the current range compared to the session average (the bars), in addition to the current session average compared to the RMA of the session averages.

What this does is essentially turn this indicator into a hybrid ATR indicator that uses session ranges for input instead of candle ranges for the purple line, but shows you the current candle range compared to the session average with the histogram of bars.

Use RMA On Session Average Bars?
If set to true, then this will apply the RMA with the given length to the bars AND the session line, turning this into an ATR indicator that uses average session ranges for input instead of candle ranges.

Convert ATR To Whole Numbers?
I recommend leaving this turned on by default unless the market you are using this indicator on behaves strangely (in which case, please contact me and I will try to fix it).

If you turn this off, then the size of the bars will shrink dramatically depending on the price range of the timeframe you are using it on. For example, since forex pairs use pips, if you were to turn this off on a pair with a range of say 0.0005, then you would barely see the bars get drawn as they would be tiny. With this feature on, a reading of 0.0005 becomes 5.0.

Draw Regular ATR?
This is optional. If turned on, then this indicator will draw the regular ATR over the top of the purple session average and the histogram of bars. That way you get the best of both worlds – the current ATR reading in relation to recent price action, as well as the current ATR reading in relation to the typical volatility to be expected during the given time of day.

Updates / Change Log


  • Added visual Stop Loss value (Green = Long Stop Price, Red = Short Stop Price)
  • Added option to calculate stop loss distance based on:
    • Regular ATR
    • ATR By Time
    • Smallest ATR (Whichever is smallest between regular ATR vs. time ATR)
    • Largest ATR (Whichever is largest between regular ATR vs time ATR)
  • Created Chart Companion Script

Free Trial

I’m a trader myself and so I know how skeptical you might be that this ATR By Time indicator is worth your time and money.

That’s why I am offering a free One Month free trial of the indicator. All you need to do to initiate your trial is Join My Mailing List!

Once you’ve subscribed to the list I’ll receive an email notifying me of your interest. As soon as I can, I’ll login to TradingView and grant you access to the indicator.

Make sure to include your TradingView username so that I can find your profile to add to the list of authenticated users.

If you have any questions during (or after) your trial you can contact me any time or leave a comment below. I look forward to hearing from you!

Monthly Subscription

If you’re happy with the indicator once your trial has finished you can purchase access to it indefinitely for a monthly fee of 4.95 USD by filling out your TradingView username and clicking the button below:

TradingView Username:

This price includes lifetime updates and support for so long as you remain a subscriber.

If you run into any issues with the indicator whatsoever then I will personally help you resolve them for as long as I’m alive, you’re subscribed, and TradingView continues to operate.

I’ll even take the time to answer any trading questions you have that are unrelated to the indicator. If you support me, I’ll support you!

Lifetime Access

Alternatively, if you have a high degree of confidence in my work and you would like to support my future work in exchange for lifetime access to all of my premium indicators, you can purchase a lifetime access license below for a one-time payment of 497 USD:

TradingView Username:

Source Code

The source code to this script is private and proprietary. As it took me a long time to create this indicator I’ve decided to keep this project’s source code hidden.

If you are a Pine Script coder and you’re curious about the formula behind this script then you can check out the source code to my free RVOL By Time indicator which is very similar.

Last Updated: 5th May, 2020

Free Premium Charts!

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments