Double Reversal Percentage Change Bar Quantitative Strategy

Author: ChaoZhang, Date: 2023-12-06 17:44:35
Tags:

img

Overview

The name of this strategy is “Double Reversal Percentage Change Bar Quantitative Strategy”. This strategy combines two different types of strategies for portfolio trading to give full play to their respective advantages and achieve better trading performance.

The first strategy uses the principle of reversal strategy to judge whether there is a reversal signal by comparing the closing price with the previous day or several days. The second strategy utilizes the “percentage change bar chart” indicator to determine the daily fluctuation range and establish positions accordingly.

Strategy Principles

The double reversal percentage change bar quantitative strategy uses two main components:

The first part is the 123 reversal strategy. Its judgment logic is:

  1. If the closing price is lower than the previous closing price and the Stoch fast line is higher than the slow line and above the 50 level, it is considered overbought and a sell signal is generated.

  2. If the closing price is higher than the previous closing price and the Stoch fast line is lower than the slow line and below 50, it is considered oversold and a buy signal is generated.

  3. Establish long or short positions according to the generated buy and sell signals.

The second part is the percentage change bar chart indicator. Its judgment logic is:

  1. Calculate the percentage change of the current bar relative to the bar N periods ago (defined by the input_barsback parameter).

  2. If the percentage change is higher than the positive value area defined by the BuyZone parameter, a buy signal is generated; if it is lower than the negative value area defined by the SellZone, a sell signal is generated.

  3. Establish long or short positions according to the generated buy and sell signals.

Finally, positions will be established only when the signals generated by the two strategies are consistent. Otherwise, there will be no change in positions.

Advantage Analysis

The double reversal percentage change bar quantitative strategy has the following advantages:

  1. It absorbs the strengths of two different types of strategies and has the potential to obtain more stable returns. The 123 reversal strategy performs well in identifying market reversal points; the percentage change bar chart indicator quickly recognizes breakout trends. The combination can identify both reversals and capture trends.

  2. The combination of signals from the two strategies can effectively filter out some false signals and reduce unnecessary stop losses to lower trading risks.

  3. The 123 reversal strategy has large optimization space. By adjusting parameter combinations, it can be optimized and adapted for different products and cycles.

  4. The percentage change bar strategy is intuitive. The trading risk is easy to grasp and control by adjusting parameters.

Risk Analysis

The double reversal percentage change bar quantitative strategy also has some risks:

  1. When the signals from the two strategies do not match, positions cannot be established, missing some trading opportunities. We can appropriately expand the parameter range of the percentage change bar chart to increase the probability of matching.

  2. The 123 reversal strategy is sensitive to parameters. Unsuitable parameter combinations may lead to too many false signals. Parameters should be tested separately for different products to ensure stability.

  3. If the direction of the buy and sell signals generated by the percentage change bar chart is wrong and matches the 123 reversal signals, it will lead to considerable losses. We should appropriately reduce the amplitude of the percentage change parameters to control risks.

  4. After the strategy has run for some time, the adaptability of the parameters will decline. We need to monitor the return curve and trading signals of the strategy to determine when to adjust the parameters.

Optimization Directions

The double reversal percentage change bar quantitative strategy can also be optimized in the following aspects:

  1. Optimize parameters like Length, KSmoothing, DLength for the 123 reversal strategy to find parameter portfolios more suitable for different products and cycles.

  2. Adjust the input_barsback parameter of the percentage change bar chart to assess the impact of longer or shorter lookback periods on the strategy.

  3. Introducing stop loss strategies can effectively avoid large losses caused by incorrect signals from percentage change bars.

  4. Attempt to train a more accurate percentage change model to determine entry and exit timing via machine learning methods to obtain higher win rate.

  5. Increase other auxiliary technical indicators for judgment to enrich trading signals from the strategy and increase trading frequency.

Conclusion

The double reversal percentage change bar quantitative strategy makes full use of the strengths of two different types of strategies and combines them to expand profit space while controlling risks. This easy-to-understand and adjustable strategy is well-suited for research and practice. With further parameter tuning and strategy optimization, it is expected to obtain more steady excess returns.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 31/03/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
//  This histogram displays price or % change from previous bar. 
//
// 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


PCB(input_percentorprice,input_barsback,SellZone,BuyZone) =>
    pos = 0.0
    xPrice = close
    xPrice1 = iff(input_percentorprice, xPrice - xPrice[input_barsback], ((xPrice - xPrice[input_barsback]) * 100)/ xPrice[input_barsback])
    pos := iff(xPrice1 > BuyZone, 1,
             iff(xPrice1 < SellZone, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Percent change bar", 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, "---- Percent change bar ----")
input_percentorprice = input(false, title="Price Change")
input_barsback = input(1, title="Look Back")
SellZone = input(-0.33, minval=0.01, step = 0.01)
BuyZone = input(0.33, minval=0.01, step = 0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPCB = PCB(input_percentorprice,input_barsback,SellZone,BuyZone)
pos = iff(posReversal123 == 1 and posPCB == 1 , 1,
	   iff(posReversal123 == -1 and posPCB == -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