Skip to content
Algo Trade Analytics Docs

ta.tr() - Pine Script Function

Calculates the current bar’s true range. Unlike a bar’s actual range (high - low), true range accounts for potential gaps by taking the maximum of the current bar’s actual range and the absolute distances from the previous bar’s close to the current bar’s high and low. The formula is: math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1])).

ta.tr(handle_na) → series float
NameTypeDescription
handle_nasimple boolDefines how the function calculates the result when the previous bar’s close is na. If true
thefunction returns the bar’s high - low value. If false
itreturns na.

True range. It is math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1])).

  • ta.tr(false) is exactly the same as ta.tr.