基于V型反转指标SMA策略

Author: ChaoZhang, Date: 2024-02-18 15:04:34
Tags:

基于V型反转指标SMA策略

概述

基于V型反转指标SMA策略通过计算股价的14天最高价与前一天最低价的绝对差值和14天最低价与前一天最高价的绝对差值,再分别计算其14日简单移动平均线,形成VI+和VI-曲线。当VI+上穿VI-时为多头信号。当VI-下穿VI+时为空头信号。

策略原理

该策略的核心指标是VI+和VI-。其中VI+反映多头力量,VI-反映空头力量。具体计算公式如下:

VMP = SUM(ABS(HIGH - LOW[1]),14)
VMM = SUM(ABS(LOW - HIGH[1]),14)  
STR = SUM(ATR(1),14)
VI+ = VMP/STR  
VI- = VMM/STR

为了去除曲线的震荡,对VI+和VI-分别计算14日简单移动平均线,得到SMA(VI+)和SMA(VI-)。当SMA(VI+)上穿SMA(VI-)时产生多头信号;当SMA(VI-)下穿SMA(VI+)时产生空头信号。

此外,策略还会结合VI+和VI-的向上向下状态来判断趋势,从而进行过滤,只在趋势向下时做多,趋势向上时做空。

优势分析

该策略结合趋势状态和VI指标的金叉死叉,可以有效过滤假信号,提高获利概率。相比简单的移动平均线策略,其突破信号更加可靠。

风险分析

该策略主要面临两个方面的风险:

  1. VI指标在某些周期内会产生误导信号。这时需要结合趋势过滤和止损来控制风险。

  2. 交易费用和滑点成本较高的市场不适合该策略,会大幅降低盈利空间。

优化方向

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

  1. 优化VI指标的周期参数,寻找最佳参数组合。

  2. 利用机器学习方法自动识别误导信号,提升信号质量。

  3. 结合止损和资金管理优化退出机制,控制单笔交易亏损。

  4. 优化交易品种选择,选择交易成本较低的市场。

总结

基于V型反转指标的SMA策略,通过计算VI+和VI-指标并结合趋势状态判断买卖时机,是一种较为可靠的趋势跟踪策略。该策略优势在于信号质量好,能有效过滤噪音。但也存在被套风险,需要不断优化以适应市场变化。


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//@author=SIDD
//Sidd-Vortex strategy is using Vortex formula  to generate 4 signals Bullish1 Bullish2 and Bearish1 Bearish2.

//Bullish1 signal is getting generated when smooth ma of VIP is crossing over smooth ma of VIM and smooth VIM is falling from previous bar smooth VIM

//Bullish2 signal is getting generated when smooth ma of VIP is crossing over smooth ma of VIM and smooth VIP is rising from previous bar smooth VIP

//Bearish1 signal is getting generated when smooth ma of VIM is crossing over smooth ma of VIP and smooth VIP is falling from previous bar smooth VIP

//Bearish2 signal is getting generated when smooth ma of VIM is crossing over smooth ma of VIP and smooth VIM is rising from previous bar smooth VIM

//This strategy can be converted into study un-commenting the plotshape and 15th line strategy replace with study and overlay=false

strategy(title = "SIDD-Vortex", shorttitle="SIDD-VORTEX", format=format.price, precision=4,overlay=true)
period_ = input(14, title="Period", minval=2)
len = input(14, minval=1, title="WMA Length")

VMP = sum( abs( high - low[1]), period_ ) // sum of absolute current high and previous low with 14 period default
VMM = sum( abs( low - high[1]), period_ ) // sum of absolute current low and previous high with 14 period default
STR = sum( atr(1), period_ )  //sum of daily atr for 14 days
VIP = VMP / STR
VIM = VMM / STR

simpleMAVIP=wma(VIP, len) 
smmaVIP = 0.0
smmaVIP := na(smmaVIP[1]) ? simpleMAVIP : (smmaVIP[1] * (len - 1) + VIP) / len // finding the Smoothing average 

simpleMAVIM=wma(VIM, len) 
smmaVIM = 0.0
smmaVIM := na(smmaVIM[1]) ? simpleMAVIM : (smmaVIM[1] * (len - 1) + VIM) / len // finding the Smoothing average 


risingVIP = rising(smmaVIP, 1)
fallingVIP = falling(smmaVIP, 1)

lineColorVIP = smmaVIP > 0.95 and risingVIP  ? color.lime : smmaVIP > 0.95 ? #d65240 : smmaVIP < 0.95 and fallingVIP ? color.red : color.olive

risingVIM = rising(VIM, 1)
fallingVIM = falling(VIM, 1)

lineColorVIM = smmaVIM > 0.95 and risingVIM  ? color.red : smmaVIM > 0.95 ? color.olive : smmaVIM < 0.95 and fallingVIM ? color.lime : #d65240

plot(VIP, title="VI +", color=lineColorVIP)
plot(VIM, title="VI -", color=lineColorVIM) 

longCondition = crossover(smmaVIP,smmaVIM)
shortCondition = crossover(smmaVIM,smmaVIP)


if (longCondition and fallingVIM)
    strategy.entry("Bullish1", strategy.long)
if (shortCondition and fallingVIP)
    strategy.entry("Bearish1", strategy.short)

if (longCondition and risingVIP)
    strategy.entry("Bullish2", strategy.long)
if (shortCondition and risingVIM)
    strategy.entry("Bearish2", strategy.short)
    
//plotshape(longCondition and fallingVIM, color=color.lime, location=location.belowbar, style=shape.triangleup,size= size.large,text="Bullish",offset=0,textcolor=color.white)
//plotshape(longCondition and risingVIP, color=color.lime, location=location.belowbar, style=shape.labelup,size= size.large,text="Bullish",offset=0,textcolor=color.white)
//plotshape(Diff > 0 and direction>0, color=color.lime, location=location.belowbar, style=shape.arrowup,size= size.normal,offset=0)
    
//plotshape(shortCondition and fallingVIP  , color=color.red, location=location.abovebar, style=shape.triangledown, size= size.large,text="Bearish",offset=0,textcolor=color.white)
//plotshape( shortCondition and risingVIM  , color=color.red, location=location.abovebar, style=shape.labeldown, size= size.large,text="Bearish",offset=0,textcolor=color.white)



//band1 = hline(1.0  , title="Upper Line", linestyle=hline.style_dashed, linewidth=3, color=color.red)
//band0 = hline(0.5, title="Lower Line", linestyle=hline.style_dashed, linewidth=3, color=color.lime)
//fill(band1, band0, color=color.purple, transp=70)




更多内容