Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
TA.MACD
TA.KDJ
TA.RSI
TA.ATR
TA.OBV
TA.MA
TA.EMA
TA.BOLL
TA.Alligator
TA.CMF
TA.Highest
TA.Lowest
TA.SMA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

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

TypeDescription

array

The return value of the TA.ATR() function is a one-dimensional array.

Arguments

NameTypeRequiredDescription

inPriceHLC

Record array

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.