多因子モデルに基づくモメント逆転戦略

作者: リン・ハーンチャオチャン,日付: 2023-12-21 16:26:10
タグ:

img

概要

マルチファクターモデルに基づくモメント逆転戦略は,より安定して高い収益を達成するために,マルチファクターモデルとモメント逆転戦略を組み合わせます.この戦略は123の逆転と合流指標を2つの独立した信号として使用し,二つの信号が一貫しているときに位置を確立します.

戦略原則

戦略は2つのサブ戦略から構成されています. 123 逆転戦略と合流指標戦略です.

123逆転戦略は,価格が2日間連続して上昇または低下したかどうかをベースに取引信号を生成し,STOCHインジケーターと組み合わせて市場が過冷または過熱しているかどうかを判断します.特に,価格が2日間連続して上昇し,9日間のSTOCHスローラインが50を下回ると上昇傾向にあります.価格が2日間連続して低下し,9日間のSTOCHファストラインが50を超えると下落傾向にあります.

収束指標戦略は,トレンド方向と強さを決定するために,異なるサイクルの移動平均値と振動器の叠加を利用する. 線形重量化,シナス加算,および長期および短期動力を包括的に判断するための他の方法を含む. インディケーターは格付けされ,強い上昇動力を示す1〜9と強い下落動力を示す-1〜9を返します.

最後に,この戦略は,両方の信号が一致している場合,ロングまたはショートポジションを設定します.

利点分析

マルチファクターモデルに基づくモメントリバーサル戦略は,逆転の機会を把握するために逆転要因とモメントファクタを組み合わせ,誤ったブレイクアウトを避けるためにトレンドに従って,より高い勝利率を得ることを意味します.この戦略の利点は特に以下に反映されています.

  1. 123の逆転戦略は,逆転信号源として,短期逆転からの過剰収益を捉えることができます.

  2. 交差点指標は,過大な逆転空間による損失のリスクを避けるために,トレンドの方向性と強さを判断します.

  3. この2つの戦略の組み合わせによって,強みや弱点が一定程度補完され,信号の質が向上します.

  4. 単一のモデルと比較して,複数の要因を組み合わせることで 戦略の安定性が向上します.

リスク分析

多因子モデルに基づくモメント逆転戦略には一定の利点があるが,依然としていくつかのリスクがある:

  1. 逆転が完了せず,価格が再び回転した結果の損失のリスク.これに対して適切なストップロスを設定することができます.

  2. 2つの信号が一致しないときの方向を決定できない.マッチング度を増やすためにパラメータ調整ができます.

  3. モデルが複雑すぎてパラメータが多すぎて 調整や最適化が難しいのです

  4. 複数のサブモデルを同時に監視する必要があるため,操作に困難と心理的プレッシャーが増加する.自動取引要素を導入することで,運用負担を軽減できます.

オプティマイゼーションの方向性

多因子モデルに基づくモメント逆転戦略は,次の側面で最適化することができる:

  1. 123 逆転戦略のパラメータを調整し,逆転信号をより正確で信頼できるものにします.

  2. 合流指標のパラメータを調整し,測定された傾向を実際の傾向に近いものにします.

  3. マシン学習アルゴリズムを導入し パラメータの組み合わせを自動的に最適化します

  4. ポジション管理モジュールを追加し,ポジション調整をより定量的で体系的にします.

  5. ストップ・ロスのモジュールを追加します. ストップ・ロスの価格を事前に設定することで単一の損失を効果的に制御します.

概要

多因子モデルに基づくモメントリバーサル戦略は,リバーサル要素とモメント要素を包括的に採用している.比較的高い信号品質を確保する基盤で,多因子スタッキングを通じてより高い勝利率を得ることができる.この戦略は,逆転機会を把握し,トレンドに従うという2つの利点がある.これは効率的で安定した定量戦略である.パラメータ調整やリスク制御などの側面でフォローアップ最適化を行うことが可能で,戦略のリスク・報酬比率をさらに改善する.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 11/11/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 is modified version of Dale Legan's "Confluence" indicator written by Gary Fritz.
// ================================================================
// Here is Gary`s commentary:
// Since the Confluence indicator returned several "states" (bull, bear, grey, and zero), 
// he modified the return value a bit:
// -9 to -1 = Bearish
// -0.9 to 0.9 = "grey" (and zero)
// 1 to 9 = Bullish
// The "grey" range corresponds to the "grey" values plotted by Dale's indicator, but 
// they're divided by 10.
//
// 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

Confluence(Harmonic, BuyBand, SellBand) =>
    pos = 0.0
    Price = close
    STL = round((Harmonic * 2) - 1 - 0.5)
    ITL = round((STL * 2) - 1 - 0.5)
    LTL = round((ITL * 2) - 1 - 0.5)
    HOFF = round(Harmonic / 2 - 0.5)
    SOFF = round(STL / 2 - 0.5)
    IOFF = round(ITL / 2 - 0.5)
    xHavg = sma(Price, Harmonic)
    xSavg = sma(Price, STL)
    xIavg = sma(Price, ITL)
    xLavg = sma(Price, LTL)
    xvalue2 = xSavg - xHavg[HOFF]
    xvalue3 = xIavg - xSavg[SOFF]
    xvalue12 = xLavg - xIavg[IOFF]
    xmomsig = xvalue2 + xvalue3 + xvalue12
    xLavgOHLC = sma(ohlc4, LTL - 1)
    xH2 = sma(Price, Harmonic - 1)
    xS2 = sma(Price, STL - 1)
    xI2 = sma(Price, ITL - 1)
    xL2 = sma(Price, LTL - 1)
    DerivH = (xHavg * 2) - xHavg[1]
    DerivS = (xSavg * 2) - xSavg[1]
    DerivI = (xIavg * 2) - xIavg[1]
    DerivL = (xLavg * 2) - xLavg[1]
    SumDH = Harmonic * DerivH
    SumDS = STL * DerivS
    SumDI = ITL * DerivI
    SumDL = LTL * DerivL
    LengH = Harmonic - 1
    LengS = STL - 1
    LengI = ITL - 1
    LengL = LTL - 1
    N1H = xH2 * LengH
    N1S = xS2 * LengS
    N1I = xI2 * LengI
    N1L = xL2 * LengL
    DRH = SumDH - N1H
    DRS = SumDS - N1S
    DRI = SumDI - N1I
    DRL = SumDL - N1L
    SumH = xH2 * (Harmonic - 1)
    SumS = xS2 * (STL - 1)
    SumI = xI2 * (ITL - 1)
    SumL = xLavgOHLC * (LTL - 1)
    xvalue5 = (SumH + DRH) / Harmonic
    xvalue6 = (SumS + DRS) / STL
    xvalue7 = (SumI + DRI) / ITL
    xvalue13 = (SumL + DRL) / LTL
    value9 = xvalue6 - xvalue5[HOFF]
    value10 = xvalue7 - xvalue6[SOFF]
    value14 = xvalue13 - xvalue7[IOFF]
    xmom = value9 + value10 + value14
    HT = sin(xvalue5 * 2 * 3.14 / 360) + cos(xvalue5 * 2 * 3.14 / 360)
    HTA = sin(xHavg * 2 * 3.14 / 360) + cos(xHavg * 2 * 3.14 / 360)
    ST = sin(xvalue6 * 2 * 3.14 / 360) + cos(xvalue6 * 2 * 3.14 / 360)
    STA = sin(xSavg * 2 * 3.14 / 360) + cos(xSavg * 2 * 3.14 / 360)
    IT = sin(xvalue7 * 2 * 3.14 / 360) + cos(xvalue7 * 2 * 3.14 / 360)
    ITA = sin(xIavg * 2 * 3.14 / 360) + cos(xIavg * 2 * 3.14 / 360)
    xSum = HT + ST + IT
    xErr = HTA + STA + ITA
    Condition2 = (((xSum > xSum[SOFF]) and (xHavg < xHavg[SOFF])) or ((xSum < xSum[SOFF]) and (xHavg > xHavg[SOFF])))
    Phase = iff(Condition2 , -1 , 1)
    xErrSum = (xSum - xErr) * Phase
    xErrSig = sma(xErrSum, SOFF)
    xvalue70 = xvalue5 - xvalue13
    xvalue71 = sma(xvalue70, Harmonic)
    ErrNum = iff (xErrSum > 0 and xErrSum < xErrSum[1] and xErrSum < xErrSig, 1,
                  iff (xErrSum > 0 and xErrSum < xErrSum[1] and xErrSum > xErrSig, 2, 
                     iff (xErrSum > 0 and xErrSum > xErrSum[1] and xErrSum < xErrSig, 2,
                         iff (xErrSum > 0 and xErrSum > xErrSum[1] and xErrSum > xErrSig, 3,
                          iff (xErrSum < 0 and xErrSum > xErrSum[1] and xErrSum > xErrSig, -1,
                             iff (xErrSum < 0 and xErrSum < xErrSum[1] and xErrSum > xErrSig, -2,
                              iff (xErrSum < 0 and xErrSum > xErrSum[1] and xErrSum < xErrSig, -2,
                                 iff (xErrSum < 0 and xErrSum < xErrSum[1] and xErrSum < xErrSig, -3, 0))))))))

    momNum = iff (xmom > 0 and xmom < xmom[1] and xmom < xmomsig , 1,
              iff (xmom > 0 and xmom < xmom[1] and xmom > xmomsig, 2,
               iff (xmom > 0 and xmom > xmom[1] and xmom < xmomsig, 2,
                 iff (xmom > 0 and xmom > xmom[1] and xmom > xmomsig, 3,
                  iff (xmom < 0 and xmom > xmom[1] and xmom > xmomsig, -1,
                   iff (xmom < 0 and xmom < xmom[1] and xmom > xmomsig, -2,
                     iff (xmom < 0 and xmom > xmom[1] and xmom < xmomsig, -2,
                      iff (xmom < 0 and xmom < xmom[1] and xmom < xmomsig, -3, 0))))))))
    
    TCNum =  iff (xvalue70 > 0 and xvalue70 < xvalue70[1] and xvalue70 < xvalue71, 1,
              iff (xvalue70 > 0 and xvalue70 < xvalue70[1] and xvalue70 > xvalue71, 2,
               iff (xvalue70 > 0 and xvalue70 > xvalue70[1] and xvalue70 < xvalue71, 2,
                 iff (xvalue70 > 0 and xvalue70 > xvalue70[1] and xvalue70 > xvalue71, 3,
                  iff (xvalue70 < 0 and xvalue70 > xvalue70[1] and xvalue70 > xvalue71, -1,
                   iff (xvalue70 < 0 and xvalue70 < xvalue70[1] and xvalue70 > xvalue71, -2,
                     iff (xvalue70 < 0 and xvalue70 > xvalue70[1] and xvalue70 < xvalue71, -2,
                      iff (xvalue70 < 0 and xvalue70 < xvalue70[1] and xvalue70 < xvalue71, -3,0))))))))
    
    value42 = ErrNum + momNum + TCNum
    Confluence = iff (value42 > 0 and xvalue70 > 0, value42,
                  iff (value42 < 0 and xvalue70 < 0, value42,
                   iff ((value42 > 0 and xvalue70 < 0) or (value42 < 0 and xvalue70 > 0), value42 / 10, 0)))
    Res1 = iff (Confluence >= 1, Confluence, 0)
    Res2 = iff (Confluence <= -1, Confluence, 0)
    Res3 = iff (Confluence == 0, 0, iff (Confluence > -1 and Confluence < 1, 10 * Confluence, 0))
    pos := iff(Res2 >= SellBand and Res2 != 0, -1,
	         iff(Res1 <= BuyBand and Res1 != 0, 1, 
    	      iff(Res3 != 0, 2, nz(pos[1], 0))))
    pos

strategy(title="Combo Backtest 123 Reversal & Confluence", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
Harmonic = input(10, minval=1)
BuyBand = input(9)
SellBand = input(-9)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posConfluence = Confluence(Harmonic, BuyBand, SellBand)
pos = iff(posReversal123 == 1 and posConfluence == 1 , 1,
	   iff(posReversal123 == -1 and posConfluence == -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 )

もっと