or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

abstract-streaming.mdcycle-indicators.mdindex.mdmath-operations.mdmomentum-indicators.mdoverlap-studies.mdpattern-recognition.mdprice-transform.mdstatistical-functions.mdvolatility-indicators.mdvolume-indicators.md

volatility-indicators.mddocs/

0

# Volatility Indicators

1

2

Measures of price volatility and range that help assess market conditions, potential breakout scenarios, and risk levels. These indicators quantify the magnitude of price movements regardless of direction.

3

4

## Capabilities

5

6

### Average True Range

7

8

Measures market volatility by calculating the average of true ranges over a specified period, providing insight into price movement magnitude.

9

10

```python { .api }

11

def ATR(high, low, close, timeperiod=14):

12

"""

13

Average True Range

14

15

Parameters:

16

- high: array-like, high prices

17

- low: array-like, low prices

18

- close: array-like, close prices

19

- timeperiod: int, number of periods (default: 14)

20

21

Returns:

22

numpy.ndarray: ATR values (absolute price units)

23

"""

24

```

25

26

### Normalized Average True Range

27

28

ATR normalized as a percentage of the closing price, allowing comparison across different price levels and securities.

29

30

```python { .api }

31

def NATR(high, low, close, timeperiod=14):

32

"""

33

Normalized Average True Range

34

35

Parameters:

36

- high: array-like, high prices

37

- low: array-like, low prices

38

- close: array-like, close prices

39

- timeperiod: int, number of periods (default: 14)

40

41

Returns:

42

numpy.ndarray: NATR values (percentage format)

43

"""

44

```

45

46

### True Range

47

48

Single-period true range calculation representing the greatest of three price differences for each period.

49

50

```python { .api }

51

def TRANGE(high, low, close):

52

"""

53

True Range

54

55

Parameters:

56

- high: array-like, high prices

57

- low: array-like, low prices

58

- close: array-like, close prices

59

60

Returns:

61

numpy.ndarray: True Range values for each period

62

"""

63

```

64

65

### Acceleration Bands

66

67

Volatility-based bands that use price acceleration to create dynamic support and resistance levels, expanding during volatile periods and contracting during quieter markets.

68

69

```python { .api }

70

def ACCBANDS(high, low, close, timeperiod=20):

71

"""

72

Acceleration Bands

73

74

Volatility-based bands using price acceleration to create dynamic

75

support and resistance levels.

76

77

Parameters:

78

- high: array-like, high prices

79

- low: array-like, low prices

80

- close: array-like, close prices

81

- timeperiod: int, number of periods (default: 20)

82

83

Returns:

84

tuple: (upper_band, middle_band, lower_band) - Three arrays representing

85

the acceleration bands

86

"""

87

```

88

89

## Usage Examples

90

91

```python

92

import talib

93

import numpy as np

94

95

# Sample OHLC data

96

high = np.array([102.5, 103.2, 101.8, 104.1, 103.7])

97

low = np.array([100.1, 101.5, 99.8, 101.2, 102.1])

98

close = np.array([101.8, 102.9, 100.5, 103.4, 102.8])

99

100

# Calculate volatility indicators

101

atr = talib.ATR(high, low, close, timeperiod=14)

102

natr = talib.NATR(high, low, close, timeperiod=14)

103

trange = talib.TRANGE(high, low, close)

104

105

print("ATR:", atr[-1])

106

print("NATR:", natr[-1], "%")

107

print("Current True Range:", trange[-1])

108

109

# ATR can be used for:

110

# - Position sizing (risk per trade = account_risk / ATR)

111

# - Stop loss placement (stop = entry ± (ATR * multiplier))

112

# - Volatility breakout systems

113

# - Market regime identification (high ATR = volatile, low ATR = quiet)

114

```