This is a combined version of 2 of my other indicators:
ADR / ATR Overlay
VOL / AVG Overlay
This indicator will display the following as an overlay on your chart:
- ADR
- % of ADR
- ADR % of Price
- ATR
- % of ATR
- ATR % of Price
- Custom Session Volume
- Average For Selected Session
- Volume Percentage Comparison
Description:
- ADR : Average Day Range
- % of ADR : Percentage that the current price move has covered its average.
- ADR % of Price : The percentage move implied by the average range.
- ATR : Average True Range
- % of ATR : Percentage that the current price move has covered its average.
- ATR % of Price : The percentage move implied by the average true range.
- Custom Session Volume : User chosen time frame to monitor volume
- Average For Selected Session : Average for the custom session volume
- Volume Percentage Comparison : Current session compared to the average (calculated at session close)
Options:
ADR/ATR:
- Time Frame
- Length
- Smoothing
Volume:
- Set Custom Time Frame For Calculations
- Set Custom Time Frame For Average Comparison
- Set Custom Time Zone
Table:
- Enable / Disable Each Value
- Change Text Color
- Change Background Color
- Change Table location
- Add/Remove extra row for placement
ADR / ATR Example:
The ADR and ATR can be used to provide information about average price moves to help set targets, stop losses, entries and exits based on the potential average moves.
Example: If the “% of ADR” is reading 100%, then 100% of the asset’s average price range has been covered, suggesting that an additional move beyond the range has a lower probability.
Example: “ADR % of Price” provides potential price movement in percentage which can be used to asses R/R for asset.
Example: ADR (D) reading is 100% at market close but ATR (D) is at 70% at close. This suggests that there is a potential (coverage) move of 30% in Pre/Post market as suggested by averages.
Custom Volume Session Example:
Set indicator to 30 period average. Set custom time frame to 9:30am to 10:30am Eastern/New York.
When the time frame for the calculation is closed, the indicator will provide a comparison of the current days volume compared to the average of 30 previous days for that same time frame and display it as a percentage in the table.
In this example you could compare how the first hour of the trading day compares to the previous 30 day’s average, aiding in evaluating the potential volume for the remainder of the day.
Notes:
Times must be entered in 24 hour format. (1pm = 13:00 etc.)
Volume indicator is for Intra-day time frames, not > Day.
How I use these values:
I use these calculations to determine if a ticker symbol has the necessary range to achieve target gains, to determine if the price oscillation is within “normal” ranges to determine if the trading day will be choppy, and to determine placement of stops and targets within average ranges in combination with support, resistance and retracement levels.
May 16
Release Notes
changed tag to “% of VOL”
// Combined ADR/ATR and VOL/AVG Overlay
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © abbadon9 [If you modify this script please acknowledge me.]
//@version=6
indicator("ADR, ATR & VOL Overlay", shorttitle="ADTR/VOL", overlay=true)
// === Inputs: ADR/ATR ===
lengthInput = input.int(14, title="ADR/ATR Length")
timeframeInput = input.timeframe("D", title="Select Timeframe for ADR & ATR Calculation")
waitForClose = input.bool(true, title="Wait for Daily Bar Close")
adrSmoothingMethod = input.string("SMA", title="ADR Smoothing", options=["SMA", "EMA", "RMA", "WMA"])
atrSmoothingMethod = input.string("RMA", title="ATR Smoothing", options=["SMA", "EMA", "RMA", "WMA"])
show_adr = input(true, title="Show ADR")
show_adr_pct = input(true, title="Show ADR % (Timeframe)")
show_adr_pct_potential = input(true, title="Show ADR % of Price (Potential Move)")
show_atr = input(true, title="Show ATR")
show_atr_pct = input(true, title="Show ATR % (Timeframe)")
show_atr_pct_potential = input(true, title="Show ATR % of Price (Potential Move)")
// === Inputs: VOL ===
selectedTz = input.string("America/New_York", "Session Timezone", options=["America/New_York", "America/Chicago", "America/Los_Angeles", "UTC", "Europe/London", "Asia/Tokyo"])
startHour = input.int(9, "Session Start Hour")
startMin = input.int(30, "Session Start Minute")
endHour = input.int(10, "Session End Hour")
endMin = input.int(30, "Session End Minute")
lookbackDays = input.int(30, "Lookback Days", minval=1)
showTodayVol = input.bool(true, "Show Today's Volume")
showAvgVol = input.bool(true, "Show 30-Day Average Volume")
showPercent = input.bool(true, "Show % of Avg")
// === Shared Display Inputs ===
bg_col = input(color.new(color.black, 100), title="Background Color")
text_col = input(color.white, title="Text Color")
addEmptyTopRow = input.bool(true, "Add Empty Top Row")
tablePosInput = input.string("Bottom Right", title="Table Position", options=["Top Left", "Top Right", "Bottom Left", "Bottom Right"])
tablePos = switch tablePosInput
"Top Left" => position.top_left
"Top Right" => position.top_right
"Bottom Left" => position.bottom_left
=> position.bottom_right
// === Daily High/Low tracking for intraday ADR% ===
var float dayHigh = na
var float dayLow = na
isNewDay = dayofweek != dayofweek[1]
if isNewDay
dayHigh := high
dayLow := low
else
dayHigh := math.max(dayHigh, high)
dayLow := math.min(dayLow, low)
/// === Function to apply smoothing ===
applySmoothing(method, src, len) =>
(method == "SMA" ? ta.sma(src, len) :
method == "EMA" ? ta.ema(src, len) :
method == "RMA" ? ta.rma(src, len) :
method == "WMA" ? ta.wma(src, len) :
na)
// === Function to calculate ADR, ATR, TR ===
calcValues() =>
highTF = high
lowTF = low
closePrevTF = close[1]
tr = math.max(highTF - lowTF, math.abs(highTF - closePrevTF), math.abs(lowTF - closePrevTF))
priceRange = highTF - lowTF
adrSmoothed = applySmoothing(adrSmoothingMethod, priceRange, lengthInput)
atrSmoothed = applySmoothing(atrSmoothingMethod, tr, lengthInput)
[adrSmoothed, atrSmoothed, tr]
// === Call ADR/ATR function using security() ===
[adr, atr, todayTR] = request.security(syminfo.tickerid, timeframeInput, calcValues(), lookahead=waitForClose ? barmerge.lookahead_on : barmerge.lookahead_off)
// === ADR/ATR Calculations ===
currentDayRange = dayHigh - dayLow
adrPct = adr != 0 ? (currentDayRange / adr) * 100 : na
adrPctStr = str.tostring(adrPct, "#.##") + "%"
atrPct = atr != 0 ? (todayTR / atr) * 100 : na
atrPctStr = str.tostring(atrPct, "#.##") + "%"
adrPotentialPct = close != 0 ? (adr / close) * 100 : na
adrPotentialPctStr = str.tostring(adrPotentialPct, "#.##") + "%"
atrPotentialPct = close != 0 ? (atr / close) * 100 : na
atrPotentialPctStr = str.tostring(atrPotentialPct, "#.##") + "%"
// === VOL Session Function ===
ff_getSessionVol() =>
sessStart = timestamp(selectedTz, year, month, dayofmonth, startHour, startMin)
sessEnd = timestamp(selectedTz, year, month, dayofmonth, endHour, endMin)
var float vol = 0.0
var bool finalized = false
if ta.change(time("D")) != 0
vol := 0.0
finalized := false
vol := (time >= sessStart and time < sessEnd) ? vol + volume : vol
finalized := finalized or (time >= sessEnd)
finalized ? vol : na
sessionFinalVol = request.security(syminfo.tickerid, "1", ff_getSessionVol())
var float[] pastVolumes = array.new_float()
if not na(sessionFinalVol) and sessionFinalVol != 0
if array.size(pastVolumes) == 0 or sessionFinalVol != array.get(pastVolumes, 0)
array.unshift(pastVolumes, sessionFinalVol)
if array.size(pastVolumes) > lookbackDays
array.pop(pastVolumes)
avgVol = array.size(pastVolumes) > 0 ? array.sum(pastVolumes) / array.size(pastVolumes) : na
percentOfAvg = (not na(avgVol) and not na(sessionFinalVol)) ? (sessionFinalVol / avgVol) * 100 : na
// === VOL Strings ===
finalVolStr = na(sessionFinalVol) ? "..." : str.tostring(sessionFinalVol, "#,###")
avgVolStr = na(avgVol) ? "..." : str.tostring(avgVol, "#,###")
percentStr = na(percentOfAvg) ? "Waiting..." : str.tostring(percentOfAvg, "#.##") + "%"
// === Unified Table Display ===
var table t = table.new(tablePos, 2, 12, bgcolor=bg_col)
if barstate.islast
int row = 0
if addEmptyTopRow
table.cell(t, 0, row, "", text_color=text_col, bgcolor=bg_col)
table.cell(t, 1, row, "", text_color=text_col, bgcolor=bg_col)
row += 1
if show_adr
table.cell(t, 0, row, "ADR (" + adrSmoothingMethod + ")", text_color=text_col)
table.cell(t, 1, row, str.tostring(adr, "#.##"), text_color=text_col)
row += 1
if show_adr_pct
table.cell(t, 0, row, "% of ADR", text_color=text_col)
table.cell(t, 1, row, adrPctStr, text_color=text_col)
row += 1
if show_adr_pct_potential
table.cell(t, 0, row, "ADR % of Price", text_color=text_col)
table.cell(t, 1, row, adrPotentialPctStr, text_color=text_col)
row += 1
if show_atr
table.cell(t, 0, row, "ATR (" + atrSmoothingMethod + ")", text_color=text_col)
table.cell(t, 1, row, str.tostring(atr, "#.##"), text_color=text_col)
row += 1
if show_atr_pct
table.cell(t, 0, row, "% of ATR", text_color=text_col)
table.cell(t, 1, row, atrPctStr, text_color=text_col)
row += 1
if show_atr_pct_potential
table.cell(t, 0, row, "ATR % of Price", text_color=text_col)
table.cell(t, 1, row, atrPotentialPctStr, text_color=text_col)
row += 1
if showTodayVol
table.cell(t, 0, row, "Session Vol", text_color=text_col)
table.cell(t, 1, row, finalVolStr, text_color=text_col)
row += 1
if showAvgVol
table.cell(t, 0, row, "Avg Vol (" + str.tostring(lookbackDays) + "d)", text_color=text_col)
table.cell(t, 1, row, avgVolStr, text_color=text_col)
row += 1
if showPercent
table.cell(t, 0, row, "% of VOL", text_color=text_col)
table.cell(t, 1, row, percentStr, text_color=text_col)
// === Alerts ===
adrPctAlertThreshold = input.float(100.0, title="ADR % Alert Threshold")
atrPctAlertThreshold = input.float(100.0, title="ATR % Alert Threshold")
enableAdrAlert = input.bool(true, "Enable ADR Alert")
enableAtrAlert = input.bool(true, "Enable ATR Alert")
alertcondition(enableAdrAlert and adrPct > adrPctAlertThreshold, title="ADR % Exceeds Threshold", message="ADR % exceeded threshold")
alertcondition(enableAtrAlert and atrPct > atrPctAlertThreshold, title="ATR % Exceeds Threshold", message="ATR % exceeded threshold")