The resource loading... loading...

Dual Confirmation Quant Trading Strategy

Author: ChaoZhang, Date: 2024-01-15 15:21:39
Tags:

img

Overview

The dual confirmation quant trading strategy realizes double confirmation of trading signals by combining the 123 reversal strategy and the Percentage Volume Oscillator (PVO) sub-strategies to reduce trading risk. This strategy is mainly suitable for medium and long-term position holding trading.

Trading Principles

123 Reversal Strategy

The 123 reversal strategy is based on K-line patterns implemented by the Stochastic indicator. Specifically, it goes long when the closing price is lower than the previous day’s closing price for two consecutive days and the 9-day slow Stochastic is below 50; it goes short when the closing price is higher than the previous day’s closing price for two consecutive days and the 9-day fast Stochastic is above 50.

Percentage Volume Oscillator (PVO)

PVO is a momentum oscillator based on volume. It measures the difference between two exponential moving averages of volume over different periods as a percentage of the longer period average. It is positive when the shorter period EMA is above the longer period EMA and negative when the shorter period EMA is below. This indicator reflects the ups and downs of trading volume.

Advantage Analysis

This strategy combines price and volume indicators to effectively filter false breaks. At the same time, by using the dual confirmation mechanism, it can reduce the frequency of transactions and lower trading risks.

Risk Analysis

This strategy relies on longer holding periods, with the risk of drawdowns. In addition, improper parameter settings can also lead to over-trading or missing signals.

Optimization Directions

The performance of sub-strategies can be optimized by adjusting the parameters of Stochastic and PVO. Stop loss mechanisms can also be introduced to control risks. In addition, filtering signals with other indicators can further improve the stability of the strategy.

Conclusion

The dual confirmation quant trading strategy takes into account both price and volume factors with good backtest results. Through parameter tuning and optimizing signal filtering, this strategy has the potential to further enhance stability and become a powerful tool for quantitative trading.


/*backtest
start: 2024-01-07 00:00:00
end: 2024-01-14 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 14/04/2021
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// The Percentage Volume Oscillator (PVO) is a momentum oscillator for volume. 
// PVO measures the difference between two volume-based moving averages as a 
// percentage of the larger moving average. As with MACD and the Percentage Price 
// Oscillator (PPO), it is shown with a signal line, a histogram and a centerline. 
// PVO is positive when the shorter volume EMA is above the longer volume EMA and 
// negative when the shorter volume EMA is below. This indicator can be used to define 
// the ups and downs for volume, which can then be use to confirm or refute other signals. 
// Typically, a breakout or support break is validated when PVO is rising or positive. 
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos


PVO(LengthShortEMA,LengthLongEMA,LengthSignalEMA) =>
    pos = 0.0
    xShortEMA = ema(volume , LengthShortEMA)
    xLongEMA = ema(volume , LengthLongEMA)
    xPVO = ((xShortEMA - xLongEMA) / xLongEMA) * 100
    xSignalEMA = ema(xPVO , LengthSignalEMA)
    xPVOHisto = xPVO - xSignalEMA
    pos := iff(xSignalEMA < xPVO, -1,
    	      iff(xSignalEMA > xPVO, 1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Percentage Volume Oscillator (PVO)", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Percentage Volume OscillatorA ----")
LengthShortEMA = input(12, minval=1)
LengthLongEMA = input(26, minval=1)
LengthSignalEMA = input(9, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPVO = PVO(LengthShortEMA,LengthLongEMA,LengthSignalEMA)
pos = iff(posReversal123 == 1 and posPVO == 1 , 1,
	   iff(posReversal123 == -1 and posPVO == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1 ) 
    strategy.entry("Long", strategy.long)
if (possig == -1 )
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )

More