策略解析:AtrRsiStrategy (ATR波动率结合RSI)
源码文件:vnpy_ctastrategy.strategies.atr_rsi_strategy 1. 策略概述 AtrRsiStrategy 是一个结合了 波动率 (ATR) 和 动量 (RSI) 的趋势突破策略。 它的核心思想是:只有在市场波动率足够大(ATR 处于高位)时,才去交易 RSI 的突破信号。这是一种典型的“过滤器”思想,旨在减少 RSI 在低波动震荡市中的假突破磨损。 基类:CtaTemplate 核心指标:ATR (Average True Range), RSI (Relative Strength Index) 风控机制:百分比移动止损 (Trailing Stop) 2. 核心参数与变量 参数名 默认值 含义 atr_length 22 计算 ATR 的窗口周期 atr_ma_length 10 计算 ATR 均线的窗口周期 rsi_length 5 计算 RSI 的窗口周期(非常灵敏) rsi_entry 16 RSI 入场阈值偏移量 (50 ± 16) trailing_percent 0.8 移动止损百分比 (0.8%) 3. 策略逻辑详解 3.1 过滤器:ATR 波动率判断 策略首先计算 ATR 值及其移动平均线 (MA)。 1 2 3 atr_array = am.atr(self.atr_length, array=True) self.atr_value = atr_array[-1] self.atr_ma = atr_array[-self.atr_ma_length:].mean() 入场前提:self.atr_value > self.atr_ma ...