
本策略通过计算交易量变化情况,判断市场趋势方向,采用趋势跟踪方式,在趋势开始阶段建立仓位,在趋势结束时平仓止损。
可以考虑加入均线系统、波动率指标等来优化入场和止损;结合更多数据源分析量价关系,防范误导信号;加入适当技术指标提升对短期调整的响应。
优化入场条件,可以考虑加入均线、자세오극점等判断,在趋势开始后确定入场。
优化止损方式,可以设定移动止损、级别止损等,让止损更贴近价格,跟踪趋势停止。
加入趋势判断环节,如ADX,可以避免横盘和震荡市场的错误交易。
优化参数设置,可以通过更长的数据回测寻找最优参数组合。
将策略扩展到更多品种,寻找质量更好、交易量更活跃的品种。
考虑加入机器学习模型,利用更多数据进行量价关系判断,提升信号质量。
本策略整体思路清晰,核心指标直观易懂,可靠地识别趋势方向。策略优势在于强调交易量变化,适合追踪中长线趋势,但需防范误导信号。通过参数优化、止损方式改进、指标优化组合等方面进行改进,可以进一步增强策略的实盘表现。
/*backtest
start: 2022-11-08 00:00:00
end: 2023-11-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Strategy for Volume Flow Indicator with alerts and markers on the chart", overlay=true)
// This indicator has been copied form Lazy Bear's code
lengthVFI = 130
coefVFI = 0.2
vcoefVFI = 2.5
signalLength= 5
smoothVFI=true
ma(x,y) => smoothVFI ? sma(x,y) : x
typical=hlc3
inter = log( typical ) - log( typical[1] )
vinter = stdev(inter, 30 )
cutoff = coefVFI * vinter * close
vave = sma( volume, lengthVFI )[1]
vmax = vave * vcoefVFI
vc = iff(volume < vmax, volume, vmax)
mf = typical - typical[1]
vcp = iff( mf > cutoff, vc, iff ( mf < -cutoff, -vc, 0 ) )
vfi = ma(sum( vcp , lengthVFI )/vave, 3)
vfima=ema( vfi, signalLength )
dVFI=vfi-vfima
bullishVFI = dVFI > 0 and dVFI[1] <=0
bearishVFI = dVFI < 0 and dVFI[1] >=0
longCondition = dVFI > 0 and dVFI[1] <=0
shortCondition = dVFI < 0 and dVFI[1] >=0
plotshape(bullishVFI, color=color.green, style=shape.labelup, textcolor=#000000, text="VFI", location=location.belowbar, transp=0)
plotshape(bearishVFI, color=color.red, style=shape.labeldown, textcolor=#ffffff, text="VFI", location=location.abovebar, transp=0)
alertcondition(bullishVFI, title='Bullish - Volume Flow Indicator', message='Bullish - Volume Flow Indicator')
alertcondition(bearishVFI, title='Bearish - Volume Flow Indicator', message='Bearish - Volume Flow Indicator')
if(year > 2018)
strategy.entry("Long", strategy.long, when=dVFI > 0 and dVFI[1] <=0)
if(shortCondition)
strategy.close(id="Long")