strategy · own pane · open source
Vortex Trend Strategy
Running…
Loading chart…
About
Vortex Indicator trend strategy: long when +VI crosses above -VI (fresh uptrend), exit on the reverse cross.
- +VI above 1.0 = strong bullish flow; below 1.0 = weak.
- Pair with an ADX filter for stronger entries.
- Combine with a higher-timeframe trend for confirmation.
Source code
//@version=5
strategy("Vortex Trend Strategy", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05)
len = input.int(14, "Length", minval=5, maxval=50, step=1)
stopPct = input.float(2, "Stop Loss %", minval=0.5, maxval=10, step=0.1)
tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
tr = math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1]))
vip = math.sum(math.abs(high - low[1]), len) / math.sum(tr, len)
vim = math.sum(math.abs(low - high[1]), len) / math.sum(tr, len)
longSignal = strategy.position_size == 0 and ta.crossover(vip, vim)
exitSignal = strategy.position_size > 0 and ta.crossunder(vip, vim)
if longSignal
strategy.entry("Long", strategy.long)
if strategy.position_size > 0
strategy.exit("Risk", stop=stopPct > 0 ? strategy.position_avg_price * (1 - stopPct / 100) : na, limit=tpPct > 0 ? strategy.position_avg_price * (1 + tpPct / 100) : na)
if exitSignal
strategy.close("Long", comment="Vortex cross down")
hline(1, "Equilibrium", color=color.gray, linestyle=hline.style_dashed)
p__VI = plot(vip, "+VI", color=color.green, linewidth=2)
p__VI = plot(vim, "-VI", color=color.red, linewidth=2)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=color.green, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=color.red, text="X")
alertcondition(longSignal, "Vortex long entry", "+VI crossed above -VI")
alertcondition(exitSignal, "Vortex exit", "+VI crossed below -VI")
No comments yet.
Sign in to comment.