0
# Volume Indicators
1
2
Indicators that analyze the relationship between price movements and trading volume to confirm trends, identify potential reversals, and validate price action. Volume analysis helps determine the strength behind price movements.
3
4
## Capabilities
5
6
### Chaikin A/D Line
7
8
Accumulation/Distribution Line that combines price and volume to show how much of a security is being accumulated or distributed.
9
10
```python { .api }
11
def AD(high, low, close, volume):
12
"""
13
Chaikin A/D Line
14
15
Parameters:
16
- high: array-like, high prices
17
- low: array-like, low prices
18
- close: array-like, close prices
19
- volume: array-like, volume data
20
21
Returns:
22
numpy.ndarray: Accumulation/Distribution Line values
23
"""
24
```
25
26
### On Balance Volume
27
28
Cumulative volume indicator that adds volume on up days and subtracts volume on down days to measure buying and selling pressure.
29
30
```python { .api }
31
def OBV(close, volume):
32
"""
33
On Balance Volume
34
35
Parameters:
36
- close: array-like, close prices
37
- volume: array-like, volume data
38
39
Returns:
40
numpy.ndarray: OBV values (cumulative volume)
41
"""
42
```
43
44
### Chaikin A/D Oscillator
45
46
Oscillator version of the Accumulation/Distribution Line, showing the momentum of accumulation/distribution.
47
48
```python { .api }
49
def ADOSC(high, low, close, volume, fastperiod=3, slowperiod=10):
50
"""
51
Chaikin A/D Oscillator
52
53
Parameters:
54
- high: array-like, high prices
55
- low: array-like, low prices
56
- close: array-like, close prices
57
- volume: array-like, volume data
58
- fastperiod: int, fast EMA period (default: 3)
59
- slowperiod: int, slow EMA period (default: 10)
60
61
Returns:
62
numpy.ndarray: A/D Oscillator values
63
"""
64
```
65
66
## Usage Examples
67
68
```python
69
import talib
70
import numpy as np
71
72
# Sample OHLCV data
73
high = np.array([10.5, 11.0, 11.2, 10.8, 11.5])
74
low = np.array([10.0, 10.3, 10.5, 10.2, 10.8])
75
close = np.array([10.3, 10.8, 10.9, 10.4, 11.2])
76
volume = np.array([1000, 1200, 800, 1500, 900])
77
78
# Calculate volume indicators
79
ad_line = talib.AD(high, low, close, volume)
80
obv = talib.OBV(close, volume)
81
ad_osc = talib.ADOSC(high, low, close, volume, fastperiod=3, slowperiod=10)
82
83
print("A/D Line:", ad_line[-1])
84
print("OBV:", obv[-1])
85
print("A/D Oscillator:", ad_osc[-1])
86
```