# 动量指标 用于趋势和强度分析的振荡器和基于动量的指标。 ## RSI - 相对强弱指数 通过比较平均涨幅和平均跌幅来衡量动量。 ### 公式 $$RS = \frac{AvgGain}{AvgLoss}$$ $$RSI = 100 - \frac{100}{1 + RS}$$ 初始平均值使用简单均值。后续值使用 Wilder 平滑: $$AvgGain_t = \frac{AvgGain_{t-1} \times (period-1) + gain_t}{period}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 2-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | period | | 内存 | O(1) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import RSI rsi = RSI(period=14) result = rsi.update(price) values = rsi.calculate(prices) # TA-Lib compatible from techkit import talib_compat as ta rsi_values = ta.RSI(prices, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const rsi = tk.rsi(14); const result = rsi.update(price); const values = tk.RSI(prices, 14); ``` ::: :::{tab-item} C++ ```cpp techkit::RSI rsi(14); auto result = rsi.update(price); ``` ::: :::{tab-item} C ```c tk_indicator rsi = tk_rsi_new(14); tk_result r = tk_update(rsi, price); tk_free(rsi); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > 70 | 超买 - 可能反转下跌 | | < 30 | 超卖 - 可能反转上涨 | | 50 | 中性 / 趋势确认 | - **背离**:价格创新高但 RSI 没有 = 看跌背离 - **失败摆动**:RSI 突破之前的摆动 = 趋势变化信号 --- ## MACD - 移动平均收敛背离 趋势跟踪动量指标,显示两个 EMA 之间的关系。 ### 公式 $$MACD = EMA(close, fast) - EMA(close, slow)$$ $$Signal = EMA(MACD, signal)$$ $$Histogram = MACD - Signal$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | fast_period | int | 12 | 2-100000 | 快线 EMA 周期 | | slow_period | int | 26 | 2-100000 | 慢线 EMA 周期 | | signal_period | int | 9 | 1-100000 | 信号线 EMA 周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 3 个值 (macd, signal, histogram) | | 回看 | slow_period - 1 + signal_period - 1 | | 内存 | O(1) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import MACD macd = MACD(fast=12, slow=26, signal=9) result = macd.update(price) if result.valid: print(f"MACD: {result.macd}, Signal: {result.signal}, Hist: {result.histogram}") # Batch - returns tuple macd_line, signal_line, histogram = macd.calculate(prices) # TA-Lib compatible from techkit import talib_compat as ta macd, signal, hist = ta.MACD(prices, fastperiod=12, slowperiod=26, signalperiod=9) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const macd = tk.macd(12, 26, 9); const result = macd.update(price); // result.macd, result.signal, result.histogram const [macdLine, signalLine, hist] = tk.MACD(prices, 12, 26, 9); ``` ::: :::{tab-item} C++ ```cpp techkit::MACD macd(12, 26, 9); auto result = macd.update_macd(price); // result.macd, result.signal, result.histogram ``` ::: :::{tab-item} C ```c tk_indicator macd = tk_macd_new(12, 26, 9); tk_macd_result r = tk_macd_update(macd, price); // r.macd, r.signal, r.histogram tk_free(macd); ``` ::: :::: ### 交易用法 | 信号 | 解释 | |------|------| | MACD 上穿信号线 | 看涨 | | MACD 下穿信号线 | 看跌 | | 柱状图增加 | 动量增强 | | 柱状图减少 | 动量减弱 | | MACD 穿越零轴 | 趋势变化 | - **背离**:价格与 MACD 背离 = 可能反转 - **柱状图**:预示 MACD/信号线交叉 --- ## STOCH - 随机振荡器 将收盘价与一段时间内的价格范围进行比较。 ### 公式 $$\%K_{raw} = \frac{close - lowest(low, k\_period)}{highest(high, k\_period) - lowest(low, k\_period)} \times 100$$ $$\%K_{slow} = SMA(\%K_{raw}, k\_slow)$$ $$\%D = SMA(\%K_{slow}, d\_period)$$ ### 参数 | 参数 | 类型 | 默认值 | 描述 | |------|------|--------|------| | k_period | int | 14 | %K 回看周期 | | k_slow | int | 3 | %K 平滑周期 | | k_matype | int | 0 | %K 均线类型 | | d_period | int | 3 | %D 平滑周期 | | d_matype | int | 0 | %D 均线类型 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 2 个值 (slowk, slowd) | | 回看 | k_period - 1 + k_slow - 1 + d_period - 1 | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import STOCH stoch = STOCH(k_period=14, k_slow=3, d_period=3) result = stoch.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"%K: {result.k}, %D: {result.d}") slowk, slowd = stoch.calculate(high_arr, low_arr, close_arr) # TA-Lib compatible from techkit import talib_compat as ta slowk, slowd = ta.STOCH(high, low, close, fastk_period=5, slowk_period=3, slowd_period=3) ``` ::: :::{tab-item} Node.js ```javascript const { STOCH } = require('techkit'); const stoch = new STOCH({ kPeriod: 14, kSlowPeriod: 3, dPeriod: 3 }); const result = stoch.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`%K: ${result.k}, %D: ${result.d}`); } const { k, d } = stoch.calculate(openArr, highArr, lowArr, closeArr, volumeArr); ``` ::: :::{tab-item} C++ ```cpp #include techkit::STOCH stoch(14, 3, 3); auto result = stoch.update_ohlcv(open, high, low, close, volume); if (result.valid) { std::cout << "%K: " << result.k << ", %D: " << result.d << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator stoch = tk_stoch_new(14, 3, 3); tk_ohlcv bar = {open, high, low, close, volume}; tk_stoch_result r = tk_stoch_update(stoch, &bar); if (r.valid) { printf("%%K: %f, %%D: %f\n", r.slowk, r.slowd); } tk_free(stoch); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > 80 | 超买 | | < 20 | 超卖 | | %K 上穿 %D | 看涨信号 | | %K 下穿 %D | 看跌信号 | --- ## ADX - 平均趋向指数 使用方向性运动来衡量趋势强度,无论方向如何。 ### 公式 $$+DM = \begin{cases} high - prev\_high & \text{if } (high - prev\_high) > (prev\_low - low) \text{ and } (high - prev\_high) > 0 \\ 0 & \text{otherwise} \end{cases}$$ $$-DM = \begin{cases} prev\_low - low & \text{if } (prev\_low - low) > (high - prev\_high) \text{ and } (prev\_low - low) > 0 \\ 0 & \text{otherwise} \end{cases}$$ $$TR = \max(high - low, |high - prev\_close|, |low - prev\_close|)$$ $$+DI = 100 \times \frac{Wilder\_smooth(+DM)}{Wilder\_smooth(TR)}$$ $$-DI = 100 \times \frac{Wilder\_smooth(-DM)}{Wilder\_smooth(TR)}$$ $$DX = 100 \times \frac{|+DI - -DI|}{+DI + -DI}$$ $$ADX = Wilder\_smooth(DX)$$ Wilder 平滑: - 第一个平滑值 = sum - sum/period + current - 后续:smoothed = smoothed - smoothed/period + current ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 1-100000 | 平滑回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 3 个值 (plus_di, minus_di, adx) | | 回看 | 2 × period - 1 | | 内存 | O(1) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import ADX adx = ADX(period=14) result = adx.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"+DI: {result.plus_di}, -DI: {result.minus_di}, ADX: {result.adx}") # TA-Lib compatible from techkit import talib_compat as ta adx_values = ta.ADX(high, low, close, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const adx = tk.adx(14); const result = adx.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`+DI: ${result.plus_di}, -DI: ${result.minus_di}, ADX: ${result.adx}`); } const adxValues = tk.ADX(highArr, lowArr, closeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::ADX adx(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_adx_result result = adx.update(bar); if (result.valid) { std::cout << "+DI: " << result.plus_di << ", -DI: " << result.minus_di << ", ADX: " << result.adx << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator adx = tk_adx_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_adx_result r = tk_adx_update(adx, &bar); if (r.valid) { printf("+DI: %f, -DI: %f, ADX: %f\n", r.plus_di, r.minus_di, r.adx); } tk_free(adx); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | ADX > 25 | 强趋势 - 适合趋势跟踪策略 | | ADX < 20 | 弱/无趋势 - 避免趋势跟踪策略 | | ADX 20-25 | 过渡区 - 趋势可能正在形成 | **方向性指标:** - **+DI > -DI**:上升趋势 - 看涨动量 - **-DI > +DI**:下降趋势 - 看跌动量 - **+DI 上穿 -DI**:看涨信号 - **-DI 上穿 +DI**:看跌信号 **综合分析:** - 高 ADX (>25) + +DI > -DI = 强上升趋势 - 高 ADX (>25) + -DI > +DI = 强下降趋势 - 低 ADX (<20) = 区间震荡市场,使用振荡器代替 --- ## 其他动量指标 [继续完整参考所有 30 个动量指标...] | 指标 | 函数 | 描述 | |------|------|------| | MOM | `MOM(period)` | 动量 (close - close[n]) | | ROC | `ROC(period)` | 变化率 % | | CCI | `CCI(period)` | 商品通道指数 | | WILLR | `WILLR(period)` | 威廉指标 %R | | APO | `APO(fast, slow)` | 绝对价格振荡器 | | PPO | `PPO(fast, slow)` | 百分比价格振荡器 | | CMO | `CMO(period)` | 钱德动量振荡器 | | TRIX | `TRIX(period)` | 三重 EMA 变化率 | | ULTOSC | `ULTOSC(p1, p2, p3)` | 终极振荡器 | | AROON | `AROON(period)` | 阿隆指标 上/下 | | AROONOSC | `AROONOSC(period)` | 阿隆振荡器 | --- ## MOM - 动量 N 个周期内的简单价格变化。 ### 公式 $$MOM = price_t - price_{t-period}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 10 | 1-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | period | | 内存 | O(period) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import MOM mom = MOM(period=10) result = mom.update(price) values = mom.calculate(prices) # TA-Lib compatible from techkit import talib_compat as ta mom_values = ta.MOM(prices, timeperiod=10) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const mom = tk.mom(10); const result = mom.update(price); const values = tk.MOM(prices, 10); ``` ::: :::{tab-item} C++ ```cpp techkit::MOM mom(10); auto result = mom.update(price); ``` ::: :::{tab-item} C ```c tk_indicator mom = tk_mom_new(10); tk_result r = tk_update(mom, price); tk_free(mom); ``` ::: :::: ### 交易用法 - **正值**:价格上涨 - **负值**:价格下跌 - **零轴穿越**:趋势变化 - **背离**:价格与动量背离信号反转 --- ## ROC - 变化率 N 个周期内的百分比变化。 ### 公式 $$ROC = \frac{price_t - price_{t-period}}{price_{t-period}} \times 100$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 10 | 1-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | period | | 内存 | O(period) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import ROC roc = ROC(period=10) result = roc.update(price) values = roc.calculate(prices) # TA-Lib compatible from techkit import talib_compat as ta roc_values = ta.ROC(prices, timeperiod=10) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const roc = tk.roc(10); const result = roc.update(price); const values = tk.ROC(prices, 10); ``` ::: :::{tab-item} C++ ```cpp techkit::ROC roc(10); auto result = roc.update(price); ``` ::: :::{tab-item} C ```c tk_indicator roc = tk_roc_new(10); tk_result r = tk_update(roc, price); tk_free(roc); ``` ::: :::: ### 交易用法 - **超买/超卖**:极值暗示反转 - **零轴**:穿越表示动量转换 --- ## ROCP - 变化率百分比 与 ROC 相同,但返回小数(不乘以 100)。 ### 公式 $$ROCP = \frac{price_t - price_{t-period}}{price_{t-period}}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 10 | 1-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | period | | 内存 | O(period) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import ROCP rocp = ROCP(period=10) result = rocp.update(price) values = rocp.calculate(prices) # TA-Lib compatible from techkit import talib_compat as ta rocp_values = ta.ROCP(prices, timeperiod=10) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const rocp = tk.rocp(10); const result = rocp.update(price); const values = tk.ROCP(prices, 10); ``` ::: :::{tab-item} C++ ```cpp techkit::ROCP rocp(10); auto result = rocp.update(price); ``` ::: :::{tab-item} C ```c tk_indicator rocp = tk_rocp_new(10); tk_result r = tk_update(rocp, price); tk_free(rocp); ``` ::: :::: ### 交易用法 - **正值**:价格上涨 - **负值**:价格下跌 - **零**:无变化 --- ## ROCR - 变化率比率 N 个周期内的价格比率。 ### 公式 $$ROCR = \frac{price_t}{price_{t-period}}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 10 | 1-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | period | | 内存 | O(period) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import ROCR rocr = ROCR(period=10) result = rocr.update(price) values = rocr.calculate(prices) # TA-Lib compatible from techkit import talib_compat as ta rocr_values = ta.ROCR(prices, timeperiod=10) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const rocr = tk.rocr(10); const result = rocr.update(price); const values = tk.ROCR(prices, 10); ``` ::: :::{tab-item} C++ ```cpp techkit::ROCR rocr(10); auto result = rocr.update(price); ``` ::: :::{tab-item} C ```c tk_indicator rocr = tk_rocr_new(10); tk_result r = tk_update(rocr, price); tk_free(rocr); ``` ::: :::: ### 交易用法 - **> 1**:价格上涨 - **< 1**:价格下跌 - **= 1**:无变化 --- ## ROCR100 - 变化率比率 × 100 ### 公式 $$ROCR100 = \frac{price_t}{price_{t-period}} \times 100$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 10 | 1-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | period | | 内存 | O(period) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import ROCR100 rocr100 = ROCR100(period=10) result = rocr100.update(price) values = rocr100.calculate(prices) # TA-Lib compatible from techkit import talib_compat as ta rocr100_values = ta.ROCR100(prices, timeperiod=10) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const rocr100 = tk.rocr100(10); const result = rocr100.update(price); const values = tk.ROCR100(prices, 10); ``` ::: :::{tab-item} C++ ```cpp techkit::ROCR100 rocr100(10); auto result = rocr100.update(price); ``` ::: :::{tab-item} C ```c tk_indicator rocr100 = tk_rocr100_new(10); tk_result r = tk_update(rocr100, price); tk_free(rocr100); ``` ::: :::: ### 交易用法 - **> 100**:价格上涨 - **< 100**:价格下跌 - **= 100**:无变化 --- ## MACDEXT - MACD 扩展 MACD,所有组件均可配置均线类型。 ### 参数 | 参数 | 类型 | 默认值 | 描述 | |------|------|--------|------| | fast_period | int | 12 | 快线均线周期 | | fast_matype | int | 0 | 快线均线类型 (0=SMA, 1=EMA...) | | slow_period | int | 26 | 慢线均线周期 | | slow_matype | int | 0 | 慢线均线类型 | | signal_period | int | 9 | 信号线均线周期 | | signal_matype | int | 0 | 信号线均线类型 | ### 均线类型值 | 值 | 类型 | |----|------| | 0 | SMA | | 1 | EMA | | 2 | WMA | | 3 | DEMA | | 4 | TEMA | | 5 | TRIMA | | 6 | KAMA | | 7 | MAMA | | 8 | T3 | --- ## MACDFIX - MACD 固定 12/26 MACD,固定 12/26 周期,仅信号周期可配置。 ### 参数 | 参数 | 类型 | 默认值 | 描述 | |------|------|--------|------| | signal_period | int | 9 | 信号线周期 | 快线和慢线周期固定为 12 和 26。 --- ## STOCHF - 快速随机 快速随机,无 %K 平滑。 ### 公式 $$Fast\%K = \frac{close - lowest(low, k\_period)}{highest(high, k\_period) - lowest(low, k\_period)} \times 100$$ $$Fast\%D = SMA(Fast\%K, d\_period)$$ ### 参数 | 参数 | 类型 | 默认值 | 描述 | |------|------|--------|------| | k_period | int | 5 | %K 回看周期 | | d_period | int | 3 | %D 平滑周期 | | d_matype | int | 0 | %D 均线类型 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 2 个值 (fastk, fastd) | | 回看 | k_period - 1 + d_period - 1 | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import STOCHF stochf = STOCHF(k_period=5, d_period=3) result = stochf.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"Fast %K: {result.k}, Fast %D: {result.d}") fastk, fastd = stochf.calculate(high_arr, low_arr, close_arr) # TA-Lib compatible from techkit import talib_compat as ta fastk, fastd = ta.STOCHF(high, low, close, fastk_period=5, fastd_period=3) ``` ::: :::{tab-item} Node.js ```javascript const { STOCHF } = require('techkit'); const stochf = new STOCHF(5, 3); const result = stochf.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`Fast %K: ${result.k}, Fast %D: ${result.d}`); } const { k, d } = stochf.calculate(openArr, highArr, lowArr, closeArr, volumeArr); ``` ::: :::{tab-item} C++ ```cpp #include techkit::STOCHF stochf(5, 3); auto result = stochf.update_ohlcv(open, high, low, close, volume); if (result.valid) { std::cout << "Fast %K: " << result.k << ", Fast %D: " << result.d << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator stochf = tk_stochf_new(5, 3); tk_ohlcv bar = {open, high, low, close, volume}; tk_stochf_result r = tk_stochf_update(stochf, &bar); if (r.valid) { printf("Fast %%K: %f, Fast %%D: %f\n", r.fastk, r.fastd); } tk_free(stochf); ``` ::: :::: ### 交易用法 类似于 STOCH,但由于缺少 %K 平滑而更敏感。信号更快但更容易产生假信号。 --- ## STOCHRSI - 随机 RSI 将随机公式应用于 RSI 值而不是价格。 ### 公式 $$RSI\_values = RSI(close, rsi\_period)$$ $$StochRSI = STOCH(RSI\_values, stoch\_period)$$ ### 参数 | 参数 | 类型 | 默认值 | 描述 | |------|------|--------|------| | rsi_period | int | 14 | RSI 周期 | | stoch_period | int | 14 | 随机周期 | | k_period | int | 3 | %K 平滑 | | d_period | int | 3 | %D 平滑 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 2 个值 (fastk, fastd) | | 回看 | rsi_period + stoch_period - 1 + k_period - 1 + d_period - 1 | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import STOCHRSI stochrsi = STOCHRSI(rsi_period=14, stoch_period=14, k_smooth=3, d_period=3) result = stochrsi.update(close) if result.valid: print(f"StochRSI %K: {result.k}, %D: {result.d}") k, d = stochrsi.calculate(close_arr) # TA-Lib compatible from techkit import talib_compat as ta fastk, fastd = ta.STOCHRSI(close, timeperiod=14, fastk_period=14, fastd_period=3, fastd_matype=0) ``` ::: :::{tab-item} Node.js ```javascript const { STOCHRSI } = require('techkit'); const stochrsi = new STOCHRSI(14, 14, 3, 3); const result = stochrsi.update(close); if (result.valid) { console.log(`StochRSI %K: ${result.k}, %D: ${result.d}`); } const { k, d } = stochrsi.calculate(closeArr); ``` ::: :::{tab-item} C++ ```cpp #include techkit::STOCHRSI stochrsi(14, 14, 3, 3); auto result = stochrsi.update(close); if (result.valid) { std::cout << "StochRSI %K: " << result.k << ", %D: " << result.d << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator stochrsi = tk_stochrsi_new(14, 14, 3, 3); tk_stochrsi_result r = tk_stochrsi_update(stochrsi, close); if (r.valid) { printf("StochRSI %%K: %f, %%D: %f\n", r.fastk, r.fastd); } tk_free(stochrsi); ``` ::: :::: ### 交易用法 比标准 RSI 或随机指标单独使用更敏感。结合动量(RSI)和超买/超卖水平(随机)。 | 水平 | 解释 | |------|------| | > 80 | 超买 | | < 20 | 超卖 | | %K 上穿 %D | 看涨信号 | | %K 下穿 %D | 看跌信号 | --- ## ADXR - 平均趋向指数评级 ADX 的平滑版本,将当前 ADX 与 N 个周期前的 ADX 进行平均。 ### 公式 $$ADXR = \frac{ADX_{today} + ADX_{period\_ago}}{2}$$ 其中 ADX 的计算方式与 ADX 指标相同。 ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 1-100000 | ADX 计算和评级的回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | 3 × period - 1 | | 内存 | O(period) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import ADXR adxr = ADXR(period=14) result = adxr.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"ADXR: {result.value}") # TA-Lib compatible from techkit import talib_compat as ta adxr_values = ta.ADXR(high, low, close, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const adxr = tk.adxr(14); const result = adxr.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`ADXR: ${result.value}`); } const adxrValues = tk.ADXR(highArr, lowArr, closeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::ADXR adxr(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = adxr.update(bar); if (result.valid) { std::cout << "ADXR: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator adxr = tk_adxr_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(adxr, &bar); if (r.valid) { printf("ADXR: %f\n", r.value); } tk_free(adxr); ``` ::: :::: ### 交易用法 ADXR 提供了比单独使用 ADX 更平滑、波动更小的趋势强度衡量。 | 水平 | 解释 | |------|------| | > 25 | 强趋势确认 | | < 20 | 弱趋势确认 | | ADXR 上升 | 趋势增强 | | ADXR 下降 | 趋势减弱 | - **比 ADX 更不敏感**:过滤噪音 - **更适合确认**:用于确认趋势强度 - **与 ADX 一起使用**:用于趋势强度分析 --- ## DX - 方向性运动指数 未经 ADX 平滑的原始方向性运动指数。衡量 +DI 和 -DI 之间的差异。 ### 公式 $$DX = 100 \times \frac{|+DI - -DI|}{+DI + -DI}$$ 其中 +DI 和 -DI 的计算方式与 ADX 相同。 ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 1-100000 | DI 计算的回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period | | 内存 | O(1) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import DX dx = DX(period=14) result = dx.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"DX: {result.value}") # TA-Lib compatible from techkit import talib_compat as ta dx_values = ta.DX(high, low, close, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const dx = tk.dx(14); const result = dx.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`DX: ${result.value}`); } const dxValues = tk.DX(highArr, lowArr, closeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::DX dx(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = dx.update(bar); if (result.valid) { std::cout << "DX: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator dx = tk_dx_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(dx, &bar); if (r.valid) { printf("DX: %f\n", r.value); } tk_free(dx); ``` ::: :::: ### 交易用法 DX 是平滑为 ADX 之前的原始方向性运动指数。比 ADX 波动更大。 - **较高值**:强方向性运动(向上或向下) - **较低值**:弱方向性运动,区间震荡市场 - **大多数交易应用使用 ADX 代替**(ADX 是平滑后的 DX) --- ## PLUS_DI - 正向方向性指标 衡量相对于真实区间的向上方向性运动强度。 ### 公式 $$+DI = 100 \times \frac{Wilder\_smooth(+DM)}{Wilder\_smooth(TR)}$$ 其中 +DM 和 TR 的计算方式与 ADX 相同。 ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 1-100000 | 平滑回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period | | 内存 | O(1) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import PLUS_DI plus_di = PLUS_DI(period=14) result = plus_di.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"+DI: {result.value}") # TA-Lib compatible from techkit import talib_compat as ta plus_di_values = ta.PLUS_DI(high, low, close, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const plusDi = tk.plusDi(14); const result = plusDi.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`+DI: ${result.value}`); } const plusDiValues = tk.PLUS_DI(highArr, lowArr, closeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::PLUS_DI plus_di(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = plus_di.update(bar); if (result.valid) { std::cout << "+DI: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator plus_di = tk_plus_di_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(plus_di, &bar); if (r.valid) { printf("+DI: %f\n", r.value); } tk_free(plus_di); ``` ::: :::: ### 交易用法 +DI 衡量向上价格运动强度。 | 条件 | 解释 | |------|------| | +DI > -DI | 上升趋势 - 看涨动量 | | +DI 上穿 -DI | 看涨信号 - 趋势转为向上 | | +DI 上升 | 向上动量增强 | | +DI 下降 | 向上动量减弱 | - **与 -DI 一起使用**:确定趋势方向 - **与 ADX 一起使用**:确认趋势强度 - **较高值**:表示更强的向上运动 --- ## MINUS_DI - 负向方向性指标 衡量相对于真实区间的向下方向性运动强度。 ### 公式 $$-DI = 100 \times \frac{Wilder\_smooth(-DM)}{Wilder\_smooth(TR)}$$ 其中 -DM 和 TR 的计算方式与 ADX 相同。 ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 1-100000 | 平滑回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period | | 内存 | O(1) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import MINUS_DI minus_di = MINUS_DI(period=14) result = minus_di.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"-DI: {result.value}") # TA-Lib compatible from techkit import talib_compat as ta minus_di_values = ta.MINUS_DI(high, low, close, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const minusDi = tk.minusDi(14); const result = minusDi.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`-DI: ${result.value}`); } const minusDiValues = tk.MINUS_DI(highArr, lowArr, closeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::MINUS_DI minus_di(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = minus_di.update(bar); if (result.valid) { std::cout << "-DI: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator minus_di = tk_minus_di_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(minus_di, &bar); if (r.valid) { printf("-DI: %f\n", r.value); } tk_free(minus_di); ``` ::: :::: ### 交易用法 -DI 衡量向下价格运动强度。 | 条件 | 解释 | |------|------| | -DI > +DI | 下降趋势 - 看跌动量 | | -DI 上穿 +DI | 看跌信号 - 趋势转为向下 | | -DI 上升 | 向下动量增强 | | -DI 下降 | 向下动量减弱 | - **与 +DI 一起使用**:确定趋势方向 - **与 ADX 一起使用**:确认趋势强度 - **较高值**:表示更强的向下运动 --- ## PLUS_DM - 正向方向性运动 原始向上方向性运动,使用 Wilder 方法平滑。 ### 公式 $$+DM = \begin{cases} high - prev\_high & \text{if } (high - prev\_high) > (prev\_low - low) \text{ and } (high - prev\_high) > 0 \ 0 & \text{otherwise} \end{cases}$$ 使用 Wilder 平滑: - 第一个平滑值 = 第一个周期值的总和 - 后续:smoothed = smoothed - smoothed/period + current ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 1-100000 | 平滑回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period - 1 | | 内存 | O(1) | | 范围 | 0 到正无穷 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import PLUS_DM plus_dm = PLUS_DM(period=14) result = plus_dm.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"+DM: {result.value}") # TA-Lib compatible from techkit import talib_compat as ta plus_dm_values = ta.PLUS_DM(high, low, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const plusDm = tk.plusDm(14); const result = plusDm.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`+DM: ${result.value}`); } const plusDmValues = tk.PLUS_DM(highArr, lowArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::PLUS_DM plus_dm(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = plus_dm.update(bar); if (result.valid) { std::cout << "+DM: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator plus_dm = tk_plus_dm_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(plus_dm, &bar); if (r.valid) { printf("+DM: %f\n", r.value); } tk_free(plus_dm); ``` ::: :::: ### 交易用法 +DM 衡量标准化之前的原始向上价格运动。 - **较高值**:强向上价格运动 - **较低值**:弱或无向上运动 - **大多数应用使用 +DI 代替**(+DI 通过真实区间标准化) - **ADX 系统的组成部分** - 很少单独使用 --- ## MINUS_DM - 负向方向性运动 原始向下方向性运动,使用 Wilder 方法平滑。 ### 公式 $$-DM = \begin{cases} prev\_low - low & \text{if } (prev\_low - low) > (high - prev\_high) \text{ and } (prev\_low - low) > 0 \\ 0 & \text{otherwise} \end{cases}$$ 使用 Wilder 平滑: - 第一个平滑值 = 第一个周期值的总和 - 后续:smoothed = smoothed - smoothed/period + current ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 1-100000 | 平滑回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period - 1 | | 内存 | O(1) | | 范围 | 0 到正无穷 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import MINUS_DM minus_dm = MINUS_DM(period=14) result = minus_dm.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"-DM: {result.value}") # TA-Lib compatible from techkit import talib_compat as ta minus_dm_values = ta.MINUS_DM(high, low, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const minusDm = tk.minusDm(14); const result = minusDm.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`-DM: ${result.value}`); } const minusDmValues = tk.MINUS_DM(highArr, lowArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::MINUS_DM minus_dm(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = minus_dm.update(bar); if (result.valid) { std::cout << "-DM: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator minus_dm = tk_minus_dm_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(minus_dm, &bar); if (r.valid) { printf("-DM: %f\n", r.value); } tk_free(minus_dm); ``` ::: :::: ### 交易用法 -DM 衡量标准化之前的原始向下价格运动。 - **较高值**:强向下价格运动 - **较低值**:弱或无向下运动 - **大多数应用使用 -DI 代替**(-DI 通过真实区间标准化) - **ADX 系统的组成部分** - 很少单独使用 --- ## CCI - 商品通道指数 使用典型价格衡量价格与其统计均值的偏差。 ### 公式 $$TP = \frac{High + Low + Close}{3}$$ $$SMA_{TP} = \frac{1}{period} \sum_{i=0}^{period-1} TP_{t-i}$$ $$MeanDeviation = \frac{1}{period} \sum_{i=0}^{period-1} |TP_{t-i} - SMA_{TP}|$$ $$CCI = \frac{TP - SMA_{TP}}{0.015 \times MeanDeviation}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 20 | 2-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV(使用典型价格) | | 输出 | 单个值 | | 回看 | period - 1 | | 内存 | O(period) | | 范围 | 通常 -100 到 +100,但无界 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import CCI cci = CCI(period=20) result = cci.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"CCI: {result.value}") values = cci.calculate(high_arr, low_arr, close_arr) # TA-Lib compatible from techkit import talib_compat as ta cci_values = ta.CCI(high, low, close, timeperiod=20) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const cci = tk.cci(20); const result = cci.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`CCI: ${result.value}`); } const cciValues = tk.CCI(highArr, lowArr, closeArr, 20); ``` ::: :::{tab-item} C++ ```cpp #include techkit::CCI cci(20); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = cci.update(bar); if (result.valid) { std::cout << "CCI: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator cci = tk_cci_new(20); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(cci, &bar); if (r.valid) { printf("CCI: %f\n", r.value); } tk_free(cci); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > +100 | 超买 - 价格显著高于均值 | | < -100 | 超卖 - 价格显著低于均值 | | 0 | 价格处于统计均值 | - **突破**:CCI > +100 或 < -100 表示强动量 - **反转**:从极值水平返回可能信号反转 - **趋势确认**:CCI 保持在零轴上方/下方确认趋势方向 --- ## CMO - 钱德动量振荡器 类似于 RSI 的动量振荡器,但范围从 -100 到 +100。 ### 公式 $$Gain = \max(close - prev\_close, 0)$$ $$Loss = \max(prev\_close - close, 0)$$ 初始周期:使用涨幅和跌幅的 SMA $$AvgGain = \frac{1}{period} \sum_{i=1}^{period} Gain_i$$ $$AvgLoss = \frac{1}{period} \sum_{i=1}^{period} Loss_i$$ 预热后:使用 Wilder 平滑(与 RSI 相同) $$AvgGain_t = \frac{AvgGain_{t-1} \times (period-1) + Gain_t}{period}$$ $$AvgLoss_t = \frac{AvgLoss_{t-1} \times (period-1) + Loss_t}{period}$$ $$CMO = 100 \times \frac{AvgGain - AvgLoss}{AvgGain + AvgLoss}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 2-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | period | | 内存 | O(1) | | 范围 | -100 到 +100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import CMO cmo = CMO(period=14) result = cmo.update(close) if result.valid: print(f"CMO: {result.value}") values = cmo.calculate(close_arr) # TA-Lib compatible from techkit import talib_compat as ta cmo_values = ta.CMO(close, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const cmo = tk.cmo(14); const result = cmo.update(close); if (result.valid) { console.log(`CMO: ${result.value}`); } const cmoValues = tk.CMO(closeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::CMO cmo(14); tk_result result = cmo.update(close); if (result.valid) { std::cout << "CMO: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator cmo = tk_cmo_new(14); tk_result r = tk_update(cmo, close); if (r.valid) { printf("CMO: %f\n", r.value); } tk_free(cmo); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > +50 | 强向上动量 | | < -50 | 强向下动量 | | 0 | 中性动量 | - **相对于 RSI 的优势**:CMO 可以显示负动量(低于 0) - **超买/超卖**:> +50 或 < -50 表示极端条件 - **零轴穿越**:动量转换信号 - **背离**:价格与 CMO 背离信号可能反转 --- ## MFI - 资金流量指数 将交易量纳入动量计算的成交量加权 RSI。 ### 公式 $$TP = \frac{High + Low + Close}{3}$$ $$RawMoneyFlow = TP \times Volume$$ $$PositiveMoneyFlow = \sum_{i=0}^{period-1} RawMF_i \text{ where } TP_i > TP_{i-1}$$ $$NegativeMoneyFlow = \sum_{i=0}^{period-1} RawMF_i \text{ where } TP_i < TP_{i-1}$$ $$MoneyFlowRatio = \frac{PositiveMoneyFlow}{NegativeMoneyFlow}$$ $$MFI = 100 - \frac{100}{1 + MoneyFlowRatio}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 2-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period | | 内存 | O(period) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import MFI mfi = MFI(period=14) result = mfi.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"MFI: {result.value}") values = mfi.calculate(high_arr, low_arr, close_arr, volume_arr) # TA-Lib compatible from techkit import talib_compat as ta mfi_values = ta.MFI(high, low, close, volume, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const mfi = tk.mfi(14); const result = mfi.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`MFI: ${result.value}`); } const mfiValues = tk.MFI(highArr, lowArr, closeArr, volumeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::MFI mfi(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = mfi.update(bar); if (result.valid) { std::cout << "MFI: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator mfi = tk_mfi_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(mfi, &bar); if (r.valid) { printf("MFI: %f\n", r.value); } tk_free(mfi); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > 80 | 超买 - 高买压 | | < 20 | 超卖 - 高卖压 | | 50 | 中性 | - **成交量确认**:MFI 使用成交量,使其比 RSI 更可靠 - **背离**:价格创新高但 MFI 没有 = 看跌背离(派发) - **价格创新低但 MFI 没有** = 看涨背离(吸筹) - **与 RSI 一起使用**:MFI 用成交量数据确认 RSI 信号 --- ## WILLR - 威廉指标 %R 类似于随机指标的动量振荡器,但反转(范围 -100 到 0)。 ### 公式 $$HighestHigh = \max(high, period)$$ $$LowestLow = \min(low, period)$$ $$WILLR = -100 \times \frac{HighestHigh - Close}{HighestHigh - LowestLow}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 2-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period - 1 | | 内存 | O(period) | | 范围 | -100 到 0 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import WILLR willr = WILLR(period=14) result = willr.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"Williams %R: {result.value}") values = willr.calculate(high_arr, low_arr, close_arr) # TA-Lib compatible from techkit import talib_compat as ta willr_values = ta.WILLR(high, low, close, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const willr = tk.willr(14); const result = willr.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`Williams %R: ${result.value}`); } const willrValues = tk.WILLR(highArr, lowArr, closeArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::WILLR willr(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = willr.update(bar); if (result.valid) { std::cout << "Williams %R: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator willr = tk_willr_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(willr, &bar); if (r.valid) { printf("Williams %%R: %f\n", r.value); } tk_free(willr); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > -20 | 超买 - 收盘价接近最高价 | | < -80 | 超卖 - 收盘价接近最低价 | | -50 | 中性 | - **反转随机指标**:WILLR = -100 × (1 - 随机指标 %K) - **超买/超卖**:更极端的值表示更强的信号 - **背离**:价格与 WILLR 背离信号可能反转 - **与随机指标一起使用**:确认随机振荡器的信号 --- ## APO - 绝对价格振荡器 衡量两个指数移动平均线之间的绝对差值。 ### 公式 $$APO = EMA(close, fast\_period) - EMA(close, slow\_period)$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | fast_period | int | 12 | 2-100000 | 快线 EMA 周期 | | slow_period | int | 26 | 2-100000 | 慢线 EMA 周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | slow_period - 1 | | 内存 | O(1) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import APO apo = APO(fast=12, slow=26) result = apo.update(close) if result.valid: print(f"APO: {result.value}") values = apo.calculate(close_arr) # TA-Lib compatible from techkit import talib_compat as ta apo_values = ta.APO(close, fastperiod=12, slowperiod=26) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const apo = tk.apo(12, 26); const result = apo.update(close); if (result.valid) { console.log(`APO: ${result.value}`); } const apoValues = tk.APO(closeArr, 12, 26); ``` ::: :::{tab-item} C++ ```cpp #include techkit::APO apo(12, 26); tk_result result = apo.update(close); if (result.valid) { std::cout << "APO: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator apo = tk_apo_new(12, 26); tk_result r = tk_update(apo, close); if (r.valid) { printf("APO: %f\n", r.value); } tk_free(apo); ``` ::: :::: ### 交易用法 | 信号 | 解释 | |------|------| | APO > 0 | 快线 EMA 高于慢线 EMA - 看涨 | | APO < 0 | 快线 EMA 低于慢线 EMA - 看跌 | | APO 上穿 0 | 看涨交叉 | | APO 下穿 0 | 看跌交叉 | | APO 增加 | 动量增强 | | APO 减少 | 动量减弱 | - **类似于 MACD**:APO 是没有信号平滑的 MACD 线 - **绝对值**:用于比较不同价格水平 - **零轴穿越**:趋势变化信号 --- ## PPO - 百分比价格振荡器 衡量两个指数移动平均线之间的百分比差值。 ### 公式 $$PPO = 100 \times \frac{EMA(close, fast\_period) - EMA(close, slow\_period)}{EMA(close, slow\_period)}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | fast_period | int | 12 | 2-100000 | 快线 EMA 周期 | | slow_period | int | 26 | 2-100000 | 慢线 EMA 周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | slow_period - 1 | | 内存 | O(1) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import PPO ppo = PPO(fast=12, slow=26) result = ppo.update(close) if result.valid: print(f"PPO: {result.value}") values = ppo.calculate(close_arr) # TA-Lib compatible from techkit import talib_compat as ta ppo_values = ta.PPO(close, fastperiod=12, slowperiod=26) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const ppo = tk.ppo(12, 26); const result = ppo.update(close); if (result.valid) { console.log(`PPO: ${result.value}`); } const ppoValues = tk.PPO(closeArr, 12, 26); ``` ::: :::{tab-item} C++ ```cpp #include techkit::PPO ppo(12, 26); tk_result result = ppo.update(close); if (result.valid) { std::cout << "PPO: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator ppo = tk_ppo_new(12, 26); tk_result r = tk_update(ppo, close); if (r.valid) { printf("PPO: %f\n", r.value); } tk_free(ppo); ``` ::: :::: ### 交易用法 | 信号 | 解释 | |------|------| | PPO > 0 | 快线 EMA 高于慢线 EMA - 看涨 | | PPO < 0 | 快线 EMA 低于慢线 EMA - 看跌 | | PPO 上穿 0 | 看涨交叉 | | PPO 下穿 0 | 看跌交叉 | - **相对于 APO 的优势**:百分比格式允许跨不同证券比较 - **标准化**:相同的百分比值意味着相同的相对动量,无论价格水平如何 - **用于投资组合分析**:比较不同股票的动量 --- ## TRIX - 三重平滑 EMA 变化率 显示三重指数平滑移动平均的百分比变化率的动量振荡器。 ### 公式 $$EMA1 = EMA(close, period)$$ $$EMA2 = EMA(EMA1, period)$$ $$EMA3 = EMA(EMA2, period)$$ $$TRIX = 100 \times \frac{EMA3_t - EMA3_{t-1}}{EMA3_{t-1}}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 30 | 2-100000 | 所有三个平滑阶段的 EMA 周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | 收盘价 | | 输出 | 单个值 | | 回看 | 3 × (period - 1) + 1 | | 内存 | O(1) | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import TRIX trix = TRIX(period=30) result = trix.update(close) if result.valid: print(f"TRIX: {result.value}") values = trix.calculate(close_arr) # TA-Lib compatible from techkit import talib_compat as ta trix_values = ta.TRIX(close, timeperiod=30) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const trix = tk.trix(30); const result = trix.update(close); if (result.valid) { console.log(`TRIX: ${result.value}`); } const trixValues = tk.TRIX(closeArr, 30); ``` ::: :::{tab-item} C++ ```cpp #include techkit::TRIX trix(30); tk_result result = trix.update(close); if (result.valid) { std::cout << "TRIX: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator trix = tk_trix_new(30); tk_result r = tk_update(trix, close); if (r.valid) { printf("TRIX: %f\n", r.value); } tk_free(trix); ``` ::: :::: ### 交易用法 | 信号 | 解释 | |------|------| | TRIX > 0 | 向上动量 | | TRIX < 0 | 向下动量 | | TRIX 上穿 0 | 看涨信号 | | TRIX 下穿 0 | 看跌信号 | - **平滑指标**:三重平滑有效过滤噪音 - **动量测量**:显示变化率,而非绝对水平 - **背离**:价格与 TRIX 背离信号可能反转 - **长回看**:默认周期 30 使其对短期波动不太敏感 --- ## ULTOSC - 终极振荡器 结合三个不同时间框架的买压来识别超买/超卖条件。 ### 公式 $$BP = Close - \min(Low, PrevClose)$$ $$TR = \max(High, PrevClose) - \min(Low, PrevClose)$$ $$Avg1 = \frac{\sum_{i=0}^{period1-1} BP_{t-i}}{\sum_{i=0}^{period1-1} TR_{t-i}}$$ $$Avg2 = \frac{\sum_{i=0}^{period2-1} BP_{t-i}}{\sum_{i=0}^{period2-1} TR_{t-i}}$$ $$Avg3 = \frac{\sum_{i=0}^{period3-1} BP_{t-i}}{\sum_{i=0}^{period3-1} TR_{t-i}}$$ $$ULTOSC = 100 \times \frac{4 \times Avg1 + 2 \times Avg2 + Avg3}{7}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period1 | int | 7 | 1-100000 | 短期周期 | | period2 | int | 14 | 1-100000 | 中期周期 | | period3 | int | 28 | 1-100000 | 长期周期 | **注意**:必须满足 period1 < period2 < period3 ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period3 | | 内存 | O(period3) | | 范围 | 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import ULTOSC ultosc = ULTOSC(period1=7, period2=14, period3=28) result = ultosc.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"Ultimate Oscillator: {result.value}") values = ultosc.calculate(high_arr, low_arr, close_arr) # TA-Lib compatible from techkit import talib_compat as ta ultosc_values = ta.ULTOSC(high, low, close, timeperiod1=7, timeperiod2=14, timeperiod3=28) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const ultosc = tk.ultosc(7, 14, 28); const result = ultosc.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`Ultimate Oscillator: ${result.value}`); } const ultoscValues = tk.ULTOSC(highArr, lowArr, closeArr, 7, 14, 28); ``` ::: :::{tab-item} C++ ```cpp #include techkit::ULTOSC ultosc(7, 14, 28); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = ultosc.update(bar); if (result.valid) { std::cout << "Ultimate Oscillator: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator ultosc = tk_ultosc_new(7, 14, 28); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(ultosc, &bar); if (r.valid) { printf("Ultimate Oscillator: %f\n", r.value); } tk_free(ultosc); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > 70 | 超买 - 可能反转下跌 | | < 30 | 超卖 - 可能反转上涨 | | 50 | 中性 | - **多时间框架**:结合短期、中期和长期动量 - **加权平均**:短期(4×)比长期(1×)权重更大 - **更少假信号**:多时间框架方法减少震荡 - **背离**:价格与 ULTOSC 背离信号可能反转 --- ## AROON - 阿隆指标 衡量周期内最高价和最低价出现后经过的时间。 ### 公式 $$AroonUp = 100 \times \frac{period - bars\_since\_highest\_high}{period}$$ $$AroonDown = 100 \times \frac{period - bars\_since\_lowest\_low}{period}$$ ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 2-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 2 个值 (aroon_up, aroon_down) | | 回看 | period | | 内存 | O(period) | | 范围 | 两个输出均为 0-100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import AROON aroon = AROON(period=14) result = aroon.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"Aroon Up: {result.up}, Aroon Down: {result.down}") up, down = aroon.calculate(high_arr, low_arr) # TA-Lib compatible from techkit import talib_compat as ta up, down = ta.AROON(high, low, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const aroon = tk.aroon(14); const result = aroon.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`Aroon Up: ${result.up}, Aroon Down: ${result.down}`); } const { up, down } = tk.AROON(highArr, lowArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::AROON aroon(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_aroon_result result = aroon.update(bar); if (result.valid) { std::cout << "Aroon Up: " << result.up << ", Aroon Down: " << result.down << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator aroon = tk_aroon_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_aroon_result r = tk_aroon_update(aroon, &bar); if (r.valid) { printf("Aroon Up: %f, Aroon Down: %f\n", r.up, r.down); } tk_free(aroon); ``` ::: :::: ### 交易用法 | 条件 | 解释 | |------|------| | Aroon Up > 70 | 强上升趋势 - 近期创新高 | | Aroon Down > 70 | 强下降趋势 - 近期创新低 | | Aroon Up 上穿 Aroon Down | 看涨信号 | | Aroon Down 上穿 Aroon Up | 看跌信号 | | 两者 < 50 | 整理/区间震荡市场 | - **趋势强度**:高 Aroon 值表示强趋势 - **趋势变化**:交叉信号潜在趋势反转 - **基于时间**:衡量自极值以来的时间,而非价格水平 - **与 AROONOSC 一起使用**:振荡器版本简化分析 --- ## AROONOSC - 阿隆振荡器 从 Aroon Up 和 Aroon Down 导出的单值振荡器。 ### 公式 $$AROONOSC = AroonUp - AroonDown$$ 其中 Aroon Up 和 Aroon Down 的计算方式与 AROON 指标相同。 ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | period | int | 14 | 2-100000 | 回看周期 | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | period | | 内存 | O(period) | | 范围 | -100 到 +100 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import AROONOSC aroonosc = AROONOSC(period=14) result = aroonosc.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"Aroon Oscillator: {result.value}") values = aroonosc.calculate(high_arr, low_arr) # TA-Lib compatible from techkit import talib_compat as ta aroonosc_values = ta.AROONOSC(high, low, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const aroonosc = tk.aroonosc(14); const result = aroonosc.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`Aroon Oscillator: ${result.value}`); } const aroonoscValues = tk.AROONOSC(highArr, lowArr, 14); ``` ::: :::{tab-item} C++ ```cpp #include techkit::AROONOSC aroonosc(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = aroonosc.update(bar); if (result.valid) { std::cout << "Aroon Oscillator: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator aroonosc = tk_aroonosc_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(aroonosc, &bar); if (r.valid) { printf("Aroon Oscillator: %f\n", r.value); } tk_free(aroonosc); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > 0 | Aroon Up > Aroon Down - 看涨 | | < 0 | Aroon Down > Aroon Up - 看跌 | | > +50 | 强上升趋势 | | < -50 | 强下降趋势 | | 穿越零轴 | 趋势变化信号 | - **简化的 Aroon**:单值而非两个值 - **零轴穿越**:信号趋势变化 - **极值**:> +50 或 < -50 表示强趋势 - **与 AROON 一起使用**:以更简单的格式提供相同信息 --- ## BOP - 多空平衡 衡量开盘价和收盘价相对于交易区间的关系。 ### 公式 $$BOP = \frac{Close - Open}{High - Low}$$ 如果 High == Low(无区间),BOP = 0。 ### 参数 | 参数 | 类型 | 默认值 | 范围 | 描述 | |------|------|--------|------|------| | None | - | - | - | 无状态指标(无参数) | ### 特性 | 属性 | 值 | |------|-----| | 输入 | OHLCV | | 输出 | 单个值 | | 回看 | 0(始终有效) | | 内存 | O(1) | | 范围 | 通常 -1 到 +1 | ### API 用法 ::::{tab-set} :::{tab-item} Python ```python from techkit import BOP bop = BOP() result = bop.update_ohlcv(open, high, low, close, volume) if result.valid: print(f"Balance of Power: {result.value}") values = bop.calculate(open_arr, high_arr, low_arr, close_arr) # TA-Lib compatible from techkit import talib_compat as ta bop_values = ta.BOP(open, high, low, close) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); const bop = tk.bop(); const result = bop.updateOHLCV({ open, high, low, close, volume }); if (result.valid) { console.log(`Balance of Power: ${result.value}`); } const bopValues = tk.BOP(openArr, highArr, lowArr, closeArr); ``` ::: :::{tab-item} C++ ```cpp #include techkit::BOP bop; tk_ohlcv bar = {open, high, low, close, volume}; tk_result result = bop.update(bar); if (result.valid) { std::cout << "Balance of Power: " << result.value << std::endl; } ``` ::: :::{tab-item} C ```c #include tk_indicator bop = tk_bop_new(); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(bop, &bar); if (r.valid) { printf("Balance of Power: %f\n", r.value); } tk_free(bop); ``` ::: :::: ### 交易用法 | 水平 | 解释 | |------|------| | > 0 | 收盘 > 开盘 - 看涨(买方控制) | | < 0 | 收盘 < 开盘 - 看跌(卖方控制) | | = +1 | 收盘 = 最高价,开盘 = 最低价 - 最大看涨 | | = -1 | 收盘 = 最低价,开盘 = 最高价 - 最大看跌 | | = 0 | 收盘 = 开盘 或 最高价 = 最低价 - 中性 | - **日内动量**:显示谁控制了 K 线(买方 vs 卖方) - **无需预热**:从第一根 K 线起始终有效(无状态) - **区间标准化**:值通过 K 线区间标准化 - **与其他指标一起使用**:确认其他振荡器的动量