TA.ATR
Calculates the Average True Range indicator (ATR).
TA.ATR(inPriceHLC)
TA.ATR(inPriceHLC, optInTimePeriod)Examples
Compute a 14-period ATR on 30-minute K-lines.
javascript
function main() {
var records = exchange.GetRecords(PERIOD_M30)
if (!records) return
var atr = TA.ATR(records, 14)
Log(atr)
// Output: an array as long as the K-lines; the warm-up part at the start is NaN
}
python
def main():
records = exchange.GetRecords(PERIOD_M30)
if not records:
return
atr = TA.ATR(records, 14)
Log(atr)
# Output: a list as long as the K-lines; the warm-up part at the start is None
rust
fn main() {
let Ok(records) = exchange.GetRecords(None, PERIOD_M30, None) else { return };
let atr = TA.ATR(&records, 14);
Log!(atr);
// Output: an array as long as the K-lines; the warm-up part at the start is NaN
}Returns
| Type | Description |
array | The return value of the |
Arguments
| Name | Type | Required | Description |
inPriceHLC |
| Yes | K-line data. |
optInTimePeriod | number | No | Calculation period. |
See Also
Remarks
The default value of the optInTimePeriod parameter of the TA.ATR() function is: 14.