本策略是一个基于波动势能指标(Vortex Indicator, VI)的趋势跟踪交易系统。该策略通过计算价格波动的正向动量(VI+)和负向动量(VI-)来识别市场趋势的转折点,并在关键的指标交叉位置产生交易信号。策略采用了平滑移动平均(SMA)来降低噪音,提高信号的可靠性。
策略的核心是通过比较VI+和VI-的相对强度来判断趋势方向。具体计算过程如下: 1. 计算正向动量(VM+)和负向动量(VM-) 2. 使用真实波幅(True Range)进行标准化处理 3. 对上述指标应用SMA平滑处理,得到最终的VI+和VI- 4. 当VI+上穿VI-时,产生做多信号;当VI+下穿VI-时,产生做空信号
该策略通过波动势能指标的创新应用,为趋势跟踪交易提供了一个可靠的分析框架。虽然存在一定的滞后性,但通过合理的参数优化和风险管理措施,可以构建出一个稳健的交易系统。建议交易者在实盘应用前进行充分的回测验证,并根据具体市场特征进行针对性优化。
/*backtest
start: 2022-02-11 00:00:00
end: 2025-02-08 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Vortex Strategy with Signals", shorttitle="VI_Strat", overlay=true)
// Užívateľský vstup
length = input.int(14, title="Period", minval=1)
//------------------------------------
// 1) Výpočet Vortexu
//------------------------------------
vmPlus = math.abs(high - low[1])
vmMinus = math.abs(low - high[1])
trueRange = math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1]))
// SMA vyhladzovanie
smoothedVMPlus = ta.sma(vmPlus, length)
smoothedVMMinus = ta.sma(vmMinus, length)
smoothedTrueRange = ta.sma(trueRange, length)
// Vortex Indikátory
viPlus = smoothedVMPlus / smoothedTrueRange
viMinus = smoothedVMMinus / smoothedTrueRange
//------------------------------------
// 2) Plot indikátora
//------------------------------------
plot(viPlus, color=color.green, title="VI+")
plot(viMinus, color=color.red, title="VI-")
//------------------------------------
// 3) Definícia signálov
//------------------------------------
bullSignal = ta.crossover(viPlus, viMinus) // VI+ pretína VI- smerom nahor
bearSignal = ta.crossunder(viPlus, viMinus) // VI+ pretína VI- smerom nadol
//------------------------------------
// 4) Vizualizácia signálov na grafe
//------------------------------------
plotshape(bullSignal,
title="Bull Signal",
style=shape.labelup,
location=location.belowbar,
color=color.green,
text="BUY",
textcolor=color.white,
size=size.small)
plotshape(bearSignal,
title="Bear Signal",
style=shape.labeldown,
location=location.abovebar,
color=color.red,
text="SELL",
textcolor=color.white,
size=size.small)
//------------------------------------
// 5) STRATEGY LOGIC
//------------------------------------
if bullSignal
strategy.entry("Long", strategy.long)
if bearSignal
strategy.entry("Short", strategy.short)