Master this powerful trend and reversal identification tool in TradingView's Pinescript for enhanced market analysis.
The Vortex Indicator (VI), developed by Etienne Botes and Douglas Siepman, is a trend-following indicator designed to identify the start of a new trend and reversals within existing trends. It's based on two oscillating lines, +VI and -VI, which reflect positive and negative price movement respectively. The core concept behind the Vortex Indicator is to quantify the strength of directional movement by relating the current range to the previous ranges, inspired by the natural phenomenon of vortices in water.
In Pinescript, the Vortex Indicator provides a clear visual representation of whether bullish or bearish pressure is dominating the market, making it a valuable tool for swing traders and trend followers alike.
The Vortex Indicator consists of two main lines: +VI (positive trend movement) and -VI (negative trend movement). Both lines oscillate around a central value, typically between 0 and 1.
The calculation involves several steps, generally over a look-back period (e.g., 14 periods):
//@version=5
indicator("My Vortex Indicator", overlay=false)
// User input for the look-back period
length = input.int(14, title="VI Length", minval=2)
// Calculate Vortex Indicator components using the built-in function
// Returns: +VI, -VI
[plusVI, minusVI] = ta.vi(length)
// Plot the +VI line (typically green)
plot(plusVI, title="+VI", color=color.green, linewidth=2)
// Plot the -VI line (typically red)
plot(minusVI, title="-VI", color=color.red, linewidth=2)
// Optional: Plot a horizontal line at 1.0 for reference (often used as a threshold)
// hline(1.0, "Threshold", color=color.gray, linestyle=hline.style_dotted)
When the `+VI` line is above the `-VI` line, it indicates a dominant uptrend. When the `-VI` line is above the `+VI` line, it indicates a dominant downtrend.
//@version=5
strategy("Vortex Crossover Strategy", overlay=true)
// Inputs for Vortex Indicator length
length = input.int(14, title="VI Length", minval=2)
// Calculate Vortex Indicator components
[plusVI, minusVI] = ta.vi(length)
// Define conditions for long and short entries
longCondition = ta.crossover(plusVI, minusVI)
shortCondition = ta.crossunder(plusVI, minusVI)
// Strategy entries
if (longCondition)
strategy.entry("Buy", strategy.long)
if (shortCondition)
strategy.entry("Sell", strategy.short)
// Optional: Plot the VI lines in a separate pane for visualization
// plot(plusVI, "+VI", color.green)
// plot(minusVI, "-VI", color.red)
// hline(1.0, "Threshold", color.gray)
//@version=5
indicator("Vortex Trend Strength", overlay=false)
length = input.int(14, title="VI Length", minval=2)
[plusVI, minusVI] = ta.vi(length)
plot(plusVI, "+VI", color.green, linewidth=2)
plot(minusVI, "-VI", color.red, linewidth=2)
// Highlight trend strength with background colors
uptrendStrong = plusVI > minusVI and plusVI > 1.1
downtrendStrong = minusVI > plusVI and minusVI > 1.1
bgcolor(uptrendStrong ? color.new(color.green, 90) : na)
bgcolor(downtrendStrong ? color.new(color.red, 90) : na)
// Plot lines at specific levels for easy visualization of strength zones
hline(1.1, "Strong Trend Zone", color=color.gray, linestyle=hline.style_dotted)
hline(0.9, "Weak Trend Zone", color=color.gray, linestyle=hline.style_dotted)
To enhance the effectiveness of the Vortex Indicator in Pinescript:
The Vortex Indicator performs best in trending markets. Its signals can be unreliable and generate whipsaws in sideways or choppy market conditions.
The Vortex Indicator is a valuable addition to any technical analyst's toolkit in Pinescript. Its unique approach to quantifying positive and negative price movement provides clear insights into trend initiation, direction, and strength. By understanding its underlying calculations and implementing it thoughtfully, especially when combined with other confirming indicators and careful market analysis, you can leverage the Vortex Indicator to improve your trend identification and trading strategies on TradingView.
Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.
This strategy runs in live mode on TradingView, helping you identify potential opportunities.
Get Pinescript Strategy