Files
QuanTAlib/lib/volatility/tr/tr.pine
T
Miha Kralj 24e86d762a Add documentation links for various volatility indicators and channels
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links.
- Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
2026-02-18 11:55:48 -08:00

23 lines
547 B
Plaintext

// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("True Range", "TR", overlay=false)
//@function Calculates the True Range
//@returns True Range value for the current bar
tr() =>
float prevClose = nz(close[1], close)
float tr1 = high - low
float tr2 = math.abs(high - prevClose)
float tr3 = math.abs(low - prevClose)
float trueRange = math.max(tr1, math.max(tr2, tr3))
trueRange
// ---------- Main loop ----------
// Calculation
trValue = tr()
// Plot
plot(trValue, "TR", color=color.yellow, linewidth=2)