The resource loading... loading...

Quantitative Trading Strategy Based on Improved Vortex Indicator

Author: ChaoZhang, Date: 2023-11-14 14:40:54
Tags:

img

Overview

This strategy is an upgraded version of the Vortex Indicator strategy. Based on the original Vortex Indicator, it incorporates several new features, including triggering trades based on threshold, smoothing vortex lines with EMA, adding stop loss and take profit, implementing long-only, short-only or long/short strategies, etc. It is suitable for investors who want to apply improved Vortex Indicator in quantitative trading.

Principles

The core indicator of this strategy is the improved Vortex Indicator. The traditional Vortex Indicator forms positive and negative vortex lines by calculating the absolute sum of price fluctuations. When the positive line crosses above the negative line, it sends a buy signal. When the negative line crosses below the positive line, it sends a sell signal.

This strategy makes the following upgrades to the traditional Vortex Indicator:

  1. Instead of solely relying on line crosses, it introduces the concept of threshold. Trades are triggered only when the spread between the positive and negative lines exceeds a preset threshold. This helps filter out small, insignificant crosses.

  2. The vortex lines are smoothed with EMA to reduce curve jitters.

  3. Stop loss and take profit functionalities are added. Loss/profit ratios can be pre-set for better risk control.

  4. Traders can choose between long-only, short-only or long/short strategies to suit different needs.

With these improvements, the strategy can more reliably detect trends and performs well in backtests.

Advantage Analysis

  1. The improved Vortex Indicator filters out invalid signals and avoids false breaks. EMA smoothing also helps reduce noise.

  2. Using threshold for signals instead of simple crosses can more reliably detect trend reversal points.

  3. The stop loss/take profit features allow pre-setting profit/loss ratios to control risks for each trade, aligning with rational trading principles.

  4. Choosing between long-only, short-only or long/short provides flexibility to adapt to different market stages and suit needs of different traders.

  5. The strategy has well-designed parameters and good backtest results, giving it practical value.

Risk Analysis

  1. The strategy mainly works for trending markets. Performance may suffer during range-bound markets.

  2. Vortex lines are inherently sensitive to price fluctuations. Improper settings may cause over-trading.

  3. If threshold is set too high, it may miss trades. If set too low, it may generate false signals. Extensive testing is needed to find the optimal levels.

  4. Stop loss may be taken out during black swan events. Traders need to be alert about this risk.

Optimization Directions

  1. Consider combining with other indicators for signal confirmation and more comprehensive judgments.

  2. Test parameter sensitivity across different stocks and optimize settings.

  3. Research adaptive stop loss techniques to adjust stops along the major trend.

  4. Introduce machine learning etc. to auto-optimize parameters.

  5. Explore indexation methods based on this strategy to expand capacity.

Conclusion

This strategy makes multiple enhancements over the traditional Vortex Indicator and forms a relatively mature and reliable quantitative trading system. Combining trend filtering and risk control, it avoids overfit risks from scattered trades and utilizes the trend capture capabilities of the indicator itself. With further parameter optimization and combination techniques, the strategy can be made more stable and responsive. Overall, it holds practical value as an upgraded version of the Vortex Indicator strategy.


/*backtest
start: 2023-10-14 00:00:00
end: 2023-11-13 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// [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", shorttitle="%-[Guz] Vortex Indicator Custom", overlay=true)

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)

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)  
 


More