Sidechair

ta.tr()

Browse the reference

Returns the true range of the current bar; the handle_na argument decides what the first bar gives.

Try it in the editor

ta.tr(handle_na) is the largest of high - low, the absolute distance from the previous close to the high, and the absolute distance from the previous close to the low. It captures gaps that a plain high-low range misses.

The first bar has no previous close. With handle_na false the result there is na; with true it falls back to high - low.

Syntax

Pine Script
ta.tr(handle_na: simple bool) -> series float

Arguments

NameTypeDefaultDescription
handle_nasimple boolfalseWhen true, the first bar returns high - low instead of na.

Returns

series float: the true range of the current bar in price units.

Remarks

  • The variable form ta.tr, written without brackets, is the same as ta.tr(false).
  • ta.atr uses the handle_na = true form.

Example

Pine ScriptTrue range against plain rangeOpen in editor
//@version=6
indicator("True range")
plot(ta.tr(true), "True range", color = color.blue)
plot(high - low, "High - low", color = color.gray)

See also

Runs on Sidechair