
动量振荡器,在 0-100 的范围内测量价格运动的速度 and 变化。值高于 70 表示超买状态,低于 30 表示超卖状态。
动量振荡器,在 0-100 的范围内测量价格运动的速度 and 变化。值高于 70 表示超买状态,低于 30 表示超卖状态。
RSI 是均值回归策略的基石。当价格显著偏离其均值(RSI > 70 或 < 30)时,交易者预期会回归平衡。与趋势跟踪指标不同,RSI 在价格围绕稳定平均值波动的震荡市场中表现出色。
了解更多关于 Mean Reversion Strategies →import backtrader as bt
class RSIMeanReversion(bt.Strategy):
params = (('rsi_period', 14), ('rsi_overbought', 70), ('rsi_oversold', 30))
def __init__(self):
self.rsi = bt.indicators.RSI(self.data.close, period=self.p.rsi_period)
def next(self):
if self.rsi[0] < self.p.rsi_oversold and not self.position:
self.buy() # Oversold: expect mean reversion upward
elif self.rsi[0] > self.p.rsi_overbought and self.position:
self.sell() # Overbought: exit on reversion| 参数 | 默认值 | 描述 |
|---|---|---|
| period | 14 | RSI 计算的回溯期 |
| upperband | 70 | 超买阈值 |
| lowerband | 30 | 超卖阈值 |