Skip to content

Latest commit

 

History

History
260 lines (167 loc) · 12.6 KB

双重反转百分比变化柱形图量化策略Double-Reversal-Percentage-Change-Bar-Quantitative-Strategy.md

File metadata and controls

260 lines (167 loc) · 12.6 KB

Name

双重反转百分比变化柱形图量化策略Double-Reversal-Percentage-Change-Bar-Quantitative-Strategy

Author

ChaoZhang

Strategy Description

IMG [trans]

概述

本策略名称为“双重反转百分比变化柱形图量化策略”。该策略综合运用了两种不同类型的策略进行组合交易,以发挥各自的优势,达到更好的交易效果。

第一种策略运用的是反转策略原理,根据收盘价与之前一日或数日的比较,配合Stoch指标判断是否出现反转信号。第二种策略则利用“百分比变化柱形图”指标,判断每日的涨跌变化幅度,作为建立仓位的依据。

策略原理

双重反转百分比变化柱形图量化策略运用两大组成部分:

第一部分是123反转策略,该策略判断逻辑是:

  1. 如果收盘价低于前一日收盘价,且Stoch快线高于慢线并高于50水平,认为处于超买状态,产生卖出信号;

  2. 如果收盘价高于前一日收盘价,且Stoch快线低于慢线并低于50水平,认为处于超卖区域,产生买入信号;

  3. 根据产生的买入和卖出信号,确立相应的多头或空头仓位。

第二部分是百分比变化柱形图指标,该指标判断逻辑是:

  1. 计算出当前K线相对于N根以前K线(参数input_barsback定义)的变化百分比;

  2. 如果变化百分比高于参数BuyZone定义的正值区域,产生买入信号;如果低于SellZone定义的负值区域,产生卖出信号;

  3. 根据产生的买入和卖出信号,确立相应的多头或空头仓位。

最后,如果两种策略产生的信号一致的时候,则实际建立仓位。如果信号不一致,则无仓位变化。

优势分析

双重反转百分比变化柱形图量化策略具有以下几大优势:

  1. 吸收两种不同类型策略各自的优点,有望获取更稳定的收益。123反转策略在判断市场反转点时表现优异;百分比变化柱形图指标对突破型行情识别快速。两者结合,既可识别反转,也可捕捉趋势。

  2. 两种策略信号组合,可以有效过滤掉一些错误信号,减少不必要的止损,降低交易风险。

  3. 123反转策略参数优化空间大,可以通过调整参数组合,针对不同品种和周期进行优化适配。

  4. 百分比变化柱形图策略直观,通过参数调整易于把握和控制交易风险。

风险分析

双重反转百分比变化柱形图量化策略也存在一些风险:

  1. 两种策略信号不匹配时无法建立仓位,会错过部分交易机会。可以适当放宽百分比变化柱形图的参数区间,增加匹配概率。

  2. 123反转策略对参数敏感,不适宜的参数组合可能导致产生过多错误信号。应对不同品种分别测试参数,确保参数稳定。

  3. 如果百分比变化柱形图产生的买卖信号方向错误,并与123反转信号匹配时,会形成较大亏损。应适当缩小变化百分比参数的区间幅度,控制风险。

  4. 策略运行一段时间后,参数的适应性会下降。需要监控策略的收益曲线和交易信号,判断参数调整的时机。

优化方向

双重反转百分比变化柱形图量化策略还可从以下几个方向进行优化:

  1. 对123反转策略的 Length、KSmoothing、DLength等参数进行优化,找到更适合不同品种和周期的参数组合。

  2. 调整百分比变化柱形图的参数input_barsback,判断更长或更短的看回期对策略的影响。

  3. 通过引入止损策略,可以有效避免百分比变化柱形图产生错误信号带来的大亏损。

  4. 尝试通过机器学习等方法,训练出更准确判断买卖时机的百分比变化模型,以获取更高的胜率。

  5. 增加其他辅助技术指标判断,丰富策略的交易信号,提高交易频率。

总结

双重反转百分比变化柱形图量化策略充分利用两种不同类型策略的优势,进行组合运用,在控制风险的同时,提高了盈利空间。该策略易于理解和优化调整,非常适合用于研究和实践。通过进一步的参数调整和策略优化,有望获得更加稳定的超额收益。

||

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.

[/trans]

Strategy Arguments

Argument Default Description
v_input_1 true ---- 123 Reversal ----
v_input_2 14 Length
v_input_3 true KSmoothing
v_input_4 3 DLength
v_input_5 50 Level
v_input_6 true ---- Percent change bar ----
v_input_7 false Price Change
v_input_8 true Look Back
v_input_9 -0.33 SellZone
v_input_10 0.33 BuyZone
v_input_11 false Trade reverse

Source (PineScript)

/*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 )

Detail

https://www.fmz.com/strategy/434484

Last Modified

2023-12-06 17:44:35