
La estrategia es un sistema de negociación basado en el análisis técnico doble basado en indicadores relativamente débiles (RSI) y bandas de Bollinger (Bollinger Bands). La estrategia construye un marco de decisión de negociación completo mediante la combinación de la señal de sobreventa y sobreventa del RSI con la señal de ruptura del canal de precios de la banda de Bollinger. La estrategia es especialmente adecuada para operar en entornos de mercado con gran volatilidad y para realizar operaciones controlables de riesgo a través de condiciones estrictas de entrada y salida.
La lógica central de la estrategia se basa en la interacción de dos indicadores técnicos principales:
La estrategia, a través de la sinergia entre el RSI y la banda de Brin, construye un sistema de negociación relativamente completo. La principal ventaja de la estrategia reside en el mecanismo de doble confirmación y el control de riesgos, pero también se debe tener en cuenta el impacto del entorno de mercado en el rendimiento de la estrategia.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI与布林带双重策略 (by ChartArt) v2.2", shorttitle="CA_RSI_布林带策略_2.2", overlay=true)
// ChartArt的RSI + 布林带双重策略 - 精简版
//
// 中文版本 3, BY Henry
// 原创意来自ChartArt,2015年1月18日
// 更新至Pine Script v5版本,删除了背景色、K线颜色和策略收益绘制功能
//
// 策略说明:
// 该策略结合使用RSI指标和布林带。
// 当价格高于上轨且RSI超买时卖出,
// 当价格低于下轨且RSI超卖时买入。
//
// 本策略仅在RSI和布林带同时
// 处于超买或超卖状态时触发。
// === 输入参数 ===
// RSI参数
RSIlength = input.int(6, title="RSI周期长度", minval=1)
RSIoverSold = input.int(50, title="RSI超卖阈值", minval=0, maxval=100)
RSIoverBought = input.int(50, title="RSI超买阈值", minval=0, maxval=100)
// 布林带参数
BBlength = input.int(200, title="布林带周期长度", minval=1)
BBmult = input.float(2.0, title="布林带标准差倍数", minval=0.001, maxval=50)
// === 计算 ===
price = close
vrsi = ta.rsi(price, RSIlength)
// 布林带计算
BBbasis = ta.sma(price, BBlength)
BBdev = BBmult * ta.stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
// === 绘图 ===
plot(BBbasis, color=color.new(color.aqua, 0), title="布林带中线(SMA)")
p1 = plot(BBupper, color=color.new(color.silver, 0), title="布林带上轨")
p2 = plot(BBlower, color=color.new(color.silver, 0), title="布林带下轨")
fill(p1, p2, color=color.new(color.silver, 90))
// === 策略逻辑 ===
if (not na(vrsi))
longCondition = ta.crossover(vrsi, RSIoverSold) and ta.crossover(price, BBlower)
if (longCondition)
strategy.entry("RSI_BB_做多", strategy.long, stop=BBlower, oca_name="RSI_BB", comment="RSI_BB_做多")
else
strategy.cancel("RSI_BB_做多")
shortCondition = ta.crossunder(vrsi, RSIoverBought) and ta.crossunder(price, BBupper)
if (shortCondition)
strategy.entry("RSI_BB_做空", strategy.short, stop=BBupper, oca_name="RSI_BB", comment="RSI_BB_做空")
else
strategy.cancel("RSI_BB_做空")