Files
strategies/双重均衡牛熊策略Dual-Balanced-Bulls-and-Bears-Strategy.md
T
2023-10-31 12:29:56 +08:00

12 KiB

Name

双重均衡牛熊策略Dual-Balanced-Bulls-and-Bears-Strategy

Author

ChaoZhang

Strategy Description

IMG

[trans]

概述

双重均衡牛熊策略是一个结合123反转策略和多空均衡指标的组合策略。该策略旨在利用123反转策略产生的信号和多空均衡指标的信号进行验证,实现更可靠的入市。

原理

该策略由两个子策略组成:

  1. 123反转策略。该策略在后两个收盘价出现反转时产生信号,即如果前两天收盘价下跌而第三天收盘价上涨时做多,如果前两天收盘价上涨而第三天收盘价下跌时做空。同时,该策略还会结合STOCH指标,只在STOCH指标显示超卖或超买时才产生信号。

  2. 多空均衡指标策略。该策略通过计算多头力量和空头力量的均衡情况,判断市场趋势。具体来说,它计算当天收盘价与开盘价的差异以及前一天与当天的差异,来判断多头力量和空头力量。多空力量差值越大,表示趋势越明确。

组合策略的交易信号来源于上述两个子策略的交易信号。只有当两个子策略的信号一致时,比如都显示做多时,组合策略才会采取该信号入场。如果两个子策略发出的信号不一致,组合策略会跳过该信号,采取观望态度。

优势

双重均衡牛熊策略最大的优势在于可靠性高。因为它要求两个子策略发出一致信号才入场,可以起到验证的作用,避免假信号。此外,两个子策略分别从反转和趋势两个方面挖掘机会,可以实现策略分散,避免单一策略的风险。

123反转策略可以捕捉短期市场的反转机会。多空均衡策略可以判断长期趋势方向。两者配合使用,可以在反转的同时把握主要趋势,过滤掉较弱的反转信号,从而提高获利概率。

风险

该策略最大的风险在于子策略发出错误信号的概率加倍。尽管组合策略要求双方信号一致,但当两个子策略同时发错信号时,组合策略也会跟着入场,从而承担双倍的损失。

此外,子策略之间可能出现分歧,一个发出做多信号,另一个做空。这时组合策略就会漏掉机会。如果分歧持续存在,组合策略可能长时间无法入场,导致资金效率下降。

优化方向

可以考虑引入 추세-역전 전략(trend-reversal strategy)作为第三个子策略。该策略可以判断长期趋势,并在趋势反转时产生信号。增加判断市场趋势的策略有助于滤除错误信号,提高稳定性。

另一个优化方向是调整子策略的参数,使它们能够产生更匹配的交易信号。比如调整多空均衡策略的阈值参数,使其能捕捉较弱的趋势,从而与反转策略形成互补。

此外,可以研究在子策略持续分歧时的处理方法。比如设定分歧的最大容忍次数,超过后采取单独子策略的信号入场。这可以在一定程度上缓解机会的损失。

总结

双重均衡牛熊策略通过组合使用123反转策略和多空均衡策略,实现交易信号的双重验证,可以有效过滤假信号,提高稳定性。同时结合反转策略和趋势策略,实现策略的分散,降低风险。该策略可进一步优化参数设定,引入第三策略等,以提高匹配度和资金效率。总体来说,该策略思路新颖,具有很强的实用价值。

||

Overview

The Dual Balanced Bulls and Bears strategy is a combination strategy that incorporates the 123 Reversal strategy and Bulls and Bears Balance indicator. It aims to verify signals from the 123 Reversal strategy with the Bulls and Bears Balance indicator for more reliable market entry.

Principles

The strategy consists of two sub-strategies:

  1. 123 Reversal strategy. It generates signals when the last two closing prices show reversal, i.e. go long when the previous two closing prices were declining while the third closing price rises, and go short when the previous two closing prices were rising while the third closing price declines. It also incorporates the STOCH indicator to only take signals when STOCH shows oversold or overbought conditions.

  2. Bulls and Bears Balance indicator strategy. It judges the market trend by calculating the balance between bullish and bearish forces. Specifically, it uses the difference between the current closing price and opening price, as well as the difference between the current and previous day to determine the bullish and bearish forces. The larger the difference between bullish and bearish forces, the more pronounced the trend.

The combined strategy sources its trading signals from the signals generated by the two sub-strategies. It will only take a signal, e.g. go long, when the two sub-strategies give consistent signals, i.e. both signal to go long. If the signals from the two sub-strategies differ, the combined strategy will skip that signal and remain sidelines.

Advantages

The biggest advantage of the Dual Balanced Bulls and Bears strategy is its high reliability. By requiring consistent signals from both sub-strategies before entering a trade, it serves as a verification mechanism to avoid false signals. In addition, with the two sub-strategies tapping opportunities from reversal and trend sides respectively, the strategy offers diversification to mitigate risks from a single strategy.

The 123 Reversal strategy can capture short-term reversal opportunities in the market. The Bulls and Bears Balance strategy can determine the direction of the longer-term trend. Using both enables capturing reversals while sticking to the major trend, filtering out weaker reversal signals and increasing win rate.

Risks

The biggest risk is that the probability of wrong signals from the sub-strategies doubles. Although the combined strategy requires consistent signals, if both sub-strategies give wrong signals at the same time, the combined strategy will still enter the trade, incurring doubled losses.

Also, conflicts can arise between the sub-strategies, with one signaling to go long while the other short. The combined strategy will then miss opportunities. Prolonged conflicts may prevent the combined strategy from entering for a long time, decreasing capital efficiency.

Optimization

Consider incorporating a trend-reversal strategy as a third sub-strategy. It can help determine the longer-term trend and give signals when the trend reverses. Adding a strategy to judge the market trend can further filter out false signals and increase stability.

Another direction is adjusting the parameters of the sub-strategies for more aligned signals. For example, adjusting the threshold parameters of the Bulls and Bears Balance strategy to capture weaker trends and complement the reversal strategy.

Handling prolonged conflicts between the sub-strategies can also be researched. For example, setting a maximum tolerance level for conflicts, after which the signal from an individual sub-strategy will be taken. This can alleviate opportunity loss to some extent.

Conclusion

The Dual Balanced Bulls and Bears strategy combines the 123 Reversal strategy and Bulls and Bears Balance strategy to achieve dual verification of trading signals and effectively filter out false signals and increase stability. Meanwhile, combining reversal and trend strategies provides diversification to lower risks. The strategy can be further optimized by adjusting parameters, adding a third strategy etc. to improve alignment and capital efficiency. Overall, the strategy has novel ideas and substantial practical value.

[/trans]

Strategy Arguments

Argument Default Description
v_input_1 14 Length
v_input_2 true KSmoothing
v_input_3 3 DLength
v_input_4 50 Level
v_input_5 -15 SellLevel
v_input_6 15 BuyLevel
v_input_7 false Trade reverse

Source (PineScript)

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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 03/07/2019
// 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 new indicator analyzes the balance between bullish and
//    bearish sentiment.
//    One can cay that it is an improved analogue of Elder Ray indicator.
//    To get more information please see "Bull And Bear Balance Indicator" 
//    by Vadim Gimelfarb. 
//
// 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

BullAndBearBalance(SellLevel, BuyLevel) =>
    pos = 0
    value =  iff (close < open , 
              iff (close[1] > open ,  max(close - open, high - low), high - low), 
               iff (close > open, 
                 iff(close[1] > open, max(close[1] - low, high - close), max(open - low, high - close)), 
                  iff(high - close > close - low, 
                   iff (close[1] > open, max(close[1] - open, high - low), high - low), 
                     iff (high - close < close - low, 
                      iff(close > open, max(close - low, high - close),open - low), 
                       iff (close > open, max(close[1] - open, high - close),
                         iff(close[1] < open, max(open - low, high - close), high - low))))))

    value2 = iff (close < open , 
              iff (close[1] < open ,  max(high - close[1], close - low), max(high - open, close - low)), 
               iff (close > open, 
                 iff(close[1] > open,  high - low, max(open - close[1], high - low)), 
                  iff(high - close > close - low, 
                   iff (close[1] < open, max(high - close[1], close - low), high - open), 
                     iff (high - close < close - low, 
                      iff(close[1] > open,  high - low, max(open - close, high - low)), 
                       iff (close[1] > open, max(high - open, close - low),
                         iff(close[1] < open, max(open - close, high - low), high - low))))))
    nBBB = value2 - value
    pos := iff(nBBB < SellLevel, -1,
    	   iff(nBBB >= BuyLevel, 1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Bull And Bear Balance", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
SellLevel = input(-15, step=0.01)
BuyLevel = input(15, step=0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBullAndBearBalance = BullAndBearBalance(SellLevel, BuyLevel)
pos = iff(posReversal123 == 1 and posBullAndBearBalance == 1 , 1,
	   iff(posReversal123 == -1 and posBullAndBearBalance == -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/430543

Last Modified

2023-10-30 10:32:53