williams_rΒΆ
Defined in fynance.features.ohlcv
- williams_r(high, low=None, close=None, w=14)[source]
Williams %R over a trailing window, causal.
\(\%R_t = -100 \cdot (HH_t - C_t) / (HH_t - LL_t)\), where
HH/LLare the rolling high/low of windoww. Bounded in[-100, 0].- Parameters:
- high, low, closearray-like, or high = OHLCV
High/Low/Close series, or a single
OHLCV.- wint, optional
Look-back window. Default 14.
- Returns:
- numpy.ndarray
Williams %R in
[-100, 0], aligned with the input.
Examples
>>> import numpy as np >>> h = np.array([10., 11., 12., 11.]) >>> low = np.array([9., 9., 10., 10.]) >>> c = np.array([9.5, 10.5, 11.5, 10.5]) >>> williams_r(h, low, c, w=2).round(2) array([-50. , -25. , -16.67, -75. ])