This strategy calculates an exponential moving average smoothed Vortex Indicator and plots the positive and negative vortex lines alongside a threshold in a separate pane.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
46 lines of Pine Script v4 from --[Guz] Vortex Indicator Custom.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
--[Guz] Vortex Indicator Custom.pine
// [Guz] Custom Vortex
// Custom version of the Vortex indicators that adds many features:
// -Triggers trades after a threshold is reached instead of the normal vortex lines cross (once the difference between the 2 lines is important enough)
// -Smooths the Vortex lines with an EMA
// -Adds Take Profit and Stop Loss selection
// -Adds the possibility to go Long only, Short only or both of them
// ! notice that it uses 10% position size and 0.04% trade fee, found on some crypto exchanges futures contracts
// Allows testing leverage with position size moddification (values above 100%, to be done with caution)
// Not an investment advice
//@version=4
strategy(title="%-[Guz] Vortex Indicator Custom - V2", shorttitle="%-[Guz] Vortex Indicator Custom - V2", overlay=false, calc_on_order_fills = false, calc_on_every_tick = false, commission_type=strategy.commission.percent, commission_value=0.04, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, initial_capital = 10000, margin_long=1, margin_short=1)
period_ = input(300, title="Length", minval=2)
VMP = sum( abs( high - low[1]), period_ )
VMM = sum( abs( low - high[1]), period_ )
STR = sum( atr(1), period_ )
ema_len = input(title="EMA Length", defval=7)
tresh= input(title="Threshold", defval=16.2, step=0.1)
VIP = ema(VMP / STR,ema_len)
VIM = ema(VMM / STR,ema_len)
plot(VIP, title="VI +", color=#2962FF)
plot(VIM, title="VI -", color=#E91E63)
plot(1+tresh/2/100, title="Threshold", color=color.green)
condition_long = crossover(VIP-VIM, tresh/100)
condition_close = cross(VIP-VIM,0)
condition_short = crossunder(VIP-VIM, -tresh/100)
is_short=input(true,title="Do Short?")
is_long=input(true,title="Do Long?")
if (condition_long and is_long)
strategy.entry("VortexLE", strategy.long, comment="Long Algo")
if (condition_short and is_short)
strategy.entry("VortexSE", strategy.short, comment="Short Algo")
if (condition_close)
strategy.close_all()
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
stop_loss_long_percent = input(2.5, title="Stop Loss Long", minval=0.1, step=0.1)
stop_loss_long = (1-stop_loss_long_percent/100)*strategy.position_avg_price
take_profit_long_percent = input(1.5, title="Take Profit Long", minval=0.1, step=0.1)
take_profit_long = (1+take_profit_long_percent/100)*strategy.position_avg_price
stop_loss_short_percent = input(2.5,title="Stop Loss Short", minval=0.1, step=0.1)
stop_loss_short = (1+stop_loss_short_percent/100)*strategy.position_avg_price
take_profit_short_percent = input(1.7,title="Take Profit Short", minval=0.1, step=0.1)
take_profit_short = (1-take_profit_short_percent/100)*strategy.position_avg_price
strategy.exit("TP-SL Long", "VortexLE", limit = take_profit_long , stop = stop_loss_long) //, trail_price = trail_price_long , trail_offset = trail_offset_long) //, trail_offset=tsl_offset_tick, trail_price=tsl_offset_tick)
strategy.exit("TP-SL Short", "VortexSE", limit = take_profit_short , stop = stop_loss_short)
Expand (62 lines)
Overview
[Guz] Vortex Indicator Custom V2 enters long when the difference between VI+ and VI- crosses above a specified positive threshold, and enters short when the difference drops below the negative threshold. Positions exit when the vortex lines cross back to zero, or upon hitting user-defined percentage-based take profit or stop loss levels. Input settings allow adjusting calculation length, smoothing EMA, threshold level, and directional trade permissions.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Length
int
300
period_
EMA Length
int
7
ema_len
Threshold
float
16.2
tresh
Do Short?
bool
true
is_short
Do Long?
bool
true
is_long
Stop Loss Long
float
2.5
stop_loss_long_percent
Take Profit Long
float
1.5
take_profit_long_percent
Stop Loss Short
float
2.5
stop_loss_short_percent
Take Profit Short
float
1.7
take_profit_short_percent
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra
This strategy combines the ATR-banded Q-Trend indicator with the Klinger Volume Oscillator (KVO) to execute confluence trades. It enters long when a Q-Trend buy trigger aligns with a positive KVO value and a bullish candle confirmation, taking short trades und
This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr
BTC MACD Basic Tests implements a Pine Script unit-testing framework designed to validate components of a long-only Bitcoin MACD trading system. It constructs structured test cases to evaluate mock functions for MACD crossover calculations, volume threshold ch
Trailering S002 is a long-only automated strategy template built for Zignaly webhook execution. It evaluates historical price stats and maximum excursion to trigger long trades, dynamically adjusting capital allocation based on active signal conditions. The sc
This strategy evaluates the dynamic relationship between price and a chosen moving average across six diagnostic dimensions: trend, respect, extension, compression, acceleration, and exhaustion. It plots a normalized relationship oscillator bounded between -10