Strategy · Pine Script v4 · Own pane

[Guz] Vortex Indicator Custom V2

by hasnocool

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.

View on GitHub

GitHub stars106on the repository
Pine versionv4older, still runs
Lines of code46
Settings9inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 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.

Details

Published by

hasnocool on GitHub

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Lengthint300period_
EMA Lengthint7ema_len
Thresholdfloat16.2tresh
Do Short?booltrueis_short
Do Long?booltrueis_long
Stop Loss Longfloat2.5stop_loss_long_percent
Take Profit Longfloat1.5take_profit_long_percent
Stop Loss Shortfloat2.5stop_loss_short_percent
Take Profit Shortfloat1.7take_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.

Similar Pine Scripts

330 stars

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

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]

Q-Trend + KVO Strategy

by TradersPost
218 stars

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

Strategy v6 TrendVolume
Updated 3 months ago · None stated GitHub repository of Q-Trend + KVO Strategy

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

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

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)

BTC MACD Basic Tests

by iamrichardD
57 stars

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

Strategy v6 Oscillators & momentumTrend
Updated 1 year ago · Apache-2.0 GitHub repository of BTC MACD Basic Tests

Trailering S002

by ruckard
13 stars

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

Strategy v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Trailering S002

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

Strategy v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of Market–Average Relationship Engine [WavesUnchained]

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers