What is the Vortex Indicator?
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 Pine Script, 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.
Components and Calculation
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):
- True Range (TR): A measure of volatility, calculated as `max(high - low, abs(high - close[1]), abs(low - close[1]))`.
- Positive Vortex Movement (+VM): Measures bullish movement: `abs(high - low[1])`.
- Negative Vortex Movement (-VM): Measures bearish movement: `abs(low - high[1])`.
- Sum of True Range (SumTR): Sum of TR over the specified period.
- Sum of +VM (Sum+VM): Sum of +VM over the specified period.
- Sum of -VM (Sum-VM): Sum of -VM over the specified period.
- +VI: `Sum+VM / SumTR`
- -VI: `Sum-VM / SumTR`
Basic Vortex Indicator Implementation in Pine Script
Pine Script v5 offers a built-in function `ta.vi()` to easily calculate the Vortex Indicator.
//@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)
Practical Vortex Indicator Strategies
1. Vortex Crossover Strategy (Entry/Exit Signals)
The primary signal generated by the Vortex Indicator is a crossover between the +VI and -VI lines. This suggests a shift in the prevailing trend.
- Bullish Crossover / Buy Signal: When `+VI` crosses above `-VI`. This indicates that positive momentum is gaining strength.
- Bearish Crossover / Sell Signal: When `-VI` crosses above `+VI`. This indicates that negative momentum is gaining strength.
//@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)
2. Trend Confirmation and Strength
Beyond simple crossovers, the Vortex Indicator can be used to confirm trends and assess their strength:
- Strong Uptrend: `+VI` is significantly above `-VI`. The wider the spread, the stronger the bullish trend.
- Strong Downtrend: `-VI` is significantly above `+VI`. The wider the spread, the stronger the bearish trend.
- Weak/Ranging Market: When the two lines are close to each other, or frequently crossing, it suggests a lack of clear trend or a choppy market.
//@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)
Optimizing Vortex Indicator Performance
To enhance the effectiveness of the Vortex Indicator in Pine Script:
- Parameter Tuning: The `length` parameter is crucial. A shorter length makes the indicator more responsive to price changes but can increase whipsaws. A longer length provides smoother signals but with more lag. Experiment to find optimal settings for your specific asset and timeframe.
- Combine with Price Action: Always confirm Vortex signals with actual price action. Look for strong candle closes, support/resistance breaks, or chart patterns.
- Multi-Timeframe Analysis: Use the Vortex Indicator on a higher timeframe to confirm the overall trend direction before taking trades based on lower timeframe signals.
- Use with Other Indicators: Pair the Vortex Indicator with other trend filters (e.g., ADX for trend strength) or oscillators (e.g., RSI for overbought/oversold conditions) to filter out false signals and improve signal quality.
Common Vortex Indicator Pitfalls
- Whipsaws: In consolidation phases or choppy markets, the +VI and -VI lines may cross frequently, generating numerous false signals.
- Lagging: While it aims to identify early trends, being based on past price data means it's still a lagging indicator. Signals might appear after a trend has already established itself.
- Over-Reliance: Using the Vortex Indicator in isolation without confluence from other technical analysis tools or fundamental factors can lead to poor trading decisions.
- Misinterpretation of Flat Lines: When both +VI and -VI are low and flat, it indicates a lack of trend. Mistaking these periods for consolidation before a strong move can be costly.
Conclusion
The Vortex Indicator is a valuable addition to any technical analyst's toolkit in Pine Script. 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.
Enhance Your Trading
Get a high-performance Pine Script 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.
Subscribe now @ $99/month