Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
talib.ATR
Calculates the Average True Range.
talib.ATR(inPriceHLC)
talib.ATR(inPriceHLC, optInTimePeriod)Examples
Compute the Average True Range from the latest K-lines.
javascript
function main() {
var records = exchange.GetRecords()
if (!records) return
var ret = talib.ATR(records)
Log(ret)
}
python
import talib
def main():
records = exchange.GetRecords()
if not records:
return
ret = talib.ATR(records.High, records.Low, records.Close)
Log(ret)Returns
| Type | Description |
numeric array | Indicator values, the same length as the input; the leading values without enough data are |
Arguments
| Name | Type | Required | Description |
inPriceHLC |
| Yes | K-line array; the high, low and close fields are used. In Python, pass |
optInTimePeriod | number | No | Calculation period. Default |
See Also
Remarks
TA-Lib equivalent: ATR(Records[High,Low,Close],Time Period = 14) = Array(outReal).