ATR

Calculates the Average True Range indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
periodNumber14-

Returns: Series<Number>

ATR is a built-in function - you can use it directly. Below is an example implementation:

1 function ATR(period = 14):
2 trueRange = Math.Max(high, close[1]) - Math.Min(low, close[1])
3 SMA(trueRange, period)