Returns the true range of the current bar; the handle_na argument decides what the first bar gives.
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
ta.tr(handle_na: simple bool) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| handle_na | simple bool | false | When 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 asta.tr(false). ta.atruses the handle_na = true form.
Example
//@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