双轨快速量化反转交易策略


创建日期: 2023-12-19 15:59:36 最后修改: 2023-12-19 15:59:36
复制: 0 点击次数: 319
1
关注
1128
关注者

双轨快速量化反转交易策略

概述

本策略是一个基于价格通道、布林带、快速RSI指标的双轨反转交易策略。它结合了通道指标识别趋势,布林带识别支撑阻力,以及快速RSI判断超买超卖的信号,实现高效的反转交易。

策略原理

该策略主要基于以下几个指标进行交易决策:

  1. 价格通道:计算一定周期内的最高价和最低价,并绘制通道中轴。价格突破通道时产生交易信号。

  2. 布林带:中轴为价格通道中轴,通过计算价格与中轴的偏离标准差构建上下轨。价格与布林带上下轨互动时产生交易信号。

  3. 快速RSI(2周期):判断价格的超买超卖情况,RSI低于5时做多,高于95时做空。

  4. CryptoBottom指标:判断价格是否跌破支持位,与快速RSI结合实现高概率做多。

根据价格突破通道、布林带时机做,以及RSI超买超卖时机做多做空,即构成该策略的核心交易逻辑。

策略优势

该策略具有以下几个优势:

  1. 双轨系统,提高信号准确率。价格通道判断大趋势,布林带识别精确支持阻力位,两者结合提升信号质量。

  2. 快速RSI指标判断超买超卖,抓住反转时机。RSI参数为2,能快速判断反转节点。

  3. CryptoBottom加快多头信号确定。跌破支持位时快速判断底部特征,避免多头信号漏失。

  4. 策略参数设置合理,容易优化。参数组合简单明了,适合参数优化。

策略风险

该策略也存在一些风险:

  1. 布林带参数设定不当,可能错过较大行情或产生假信号。

  2. 双轨互动模式复杂,需要一定技术积累正确判断。

  3. 反转失败风险仍然存在,无法完全避免行情再次拉回的概率。

  4. 参数优化困难,最优参数可能因市场环境改变而失效。

策略优化方向

该策略可以从以下几个方向进行优化:

  1. 优化布林带的参数,使上下轨更贴近价格,提高信号准确率。

  2. 增加止损策略,在亏损达到一定比例时止损,有效控制风险。

  3. 结合更多指标,判断趋势、支持阻力位,减少假信号。

  4. 增加机器学习算法,自动优化参数,使之能应对市场环境变化。

总结

本策略整合价格通道、布林带和快速RSI指标,构建双轨反转交易体系。在判断大趋势的同时,快速抓住支持阻力与超买超卖机会。参数设置简单直接,容易理解和优化。能够有效识别反转机会,适合量化交易。

策略源码
/*backtest
start: 2022-12-18 00:00:00
end: 2023-11-30 05:20:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/


//@version=2
strategy("Noro's Bands Strategy v1.3", shorttitle = "NoroBands str 1.3", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
len = input(20, defval = 20, minval = 2, maxval = 200, title = "Period")
color = input(true, "Use ColorBar")
usecb = input(true, "Use CryptoBottom")
usersi = input(true, "Use RSI")
needbb = input(false, defval = false, title = "Show Bands")
needbg = input(false, defval = false, title = "Show Background")
src = close

//Fast RSI
fastup = rma(max(change(src), 0), 2)
fastdown = rma(-min(change(src), 0), 2)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))

//CryptoBottom
mac = sma(close, 10)
lencb = abs(close - mac)
sma = sma(lencb, 100)
max = max(open, close)
min = min(open, close)

//PriceChannel
lasthigh = highest(src, len)
lastlow = lowest(src, len)
center = (lasthigh + lastlow) / 2

//dist
dist = abs(src - center)
distsma = sma(dist, len)
hd = center + distsma
ld = center - distsma

//Trend
trend = close < ld and high < hd ? -1 : close > hd and low > ld ? 1 : trend[1]

//Lines
colo = needbb == false ? na : black
plot(hd, color = colo, linewidth = 1, transp = 0, title = "High band")
plot(center, color = colo, linewidth = 1, transp = 0, title = "center")
plot(ld, color = colo, linewidth = 1, transp = 0, title = "Low band")

//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 80)

//Signals
up = trend == 1 and ((close < open or color == false) or close < hd) ? 1 : 0
dn = trend == -1 and ((close > open or color == false) or close > ld) ? 1 : 0 
up2 = close < open and lencb > sma * 3 and min < min[1] and fastrsi < 10 ? 1 : 0 //CryptoBottom
//dn2 = close > open and len > sma * 3 and max > max[1] and fastrsi > 90 ? 1 : 0 //CryptoBottom
up3 = fastrsi < 5 ? 1 : 0
//dn3 = fastrsi > 99 ? 1 : 0

longCondition = up == 1 or (up2 == 1 and usecb == true) or (up3 == 1 and usersi == true)
if (longCondition)
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na)

shortCondition = dn == 1
if (shortCondition)
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
更多内容