3バーと4バーのブレイクアウト逆転戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-18 10:39:53
タグ:

img

概要

3バーと4バーのブレイアウトリバーション戦略は,強い勢力を有する3つまたは4つのK線バーを特定し,いくつかの小さな範囲のKバーがサポート/レジスタンスレベルを形成し,逆転信号が出現した後,反トレンド取引を行う.これは平均リバーション戦略に属する.

戦略の論理

この戦略の基本的識別論理には,以下の要素が含まれます.

  1. 大距離バー (Gap Bars) を認識する: 1.5 x ATR を割る.体比が65%以上である.彼らは強い勢いを持っていると考えられる.

  2. 低レンジバー (Collecting Bars) を認識する:ギャップバーの後に続く1つまたは2つの次のような小レンジバー,ギャップバーに近い高/低レベル.それらは減速するモメンタムと統合を表し,サポート/レジスタンスレベルを形成する.

  3. 逆転信号バーを認識する: 結合後,バーが前のバーの高/低を突破した場合,逆転信号とみなすことができます. 信号バーの方向に基づいてポジションを取ります.

  4. ストップ・ロストとテイク・プロフィート:Gap Barの低点/高点以下/上位にストップ・ロストを設定する.テイク・プロフィートは,ストップ・ロスト距離とリスク・リターン比を掛けることで決定される.

利点分析

この戦略の主な利点は:

  1. 原価の動きを用いてトレンドと逆転を特定し,指標は必要ありません.

  2. ギャップバーと集積バーに関する厳格な規則は,実際の動向と統合を正確に把握することを保証します.

  3. 逆転棒を体によって判断すると 誤った信号が減少します

  4. 取引は3~4バーで 高い周波数で 短い保持期間です

  5. ストップ・ロストとテイク・プロフィートの 明確なルールにより リスク管理が容易になります

リスク分析

主なリスクは

  1. パラメータ設定に頼る フレッシュなパラメータは 誤った信号と失敗する取引を増やす

  2. 偽の脱出に脆弱で 偽の信号をフィルタリングできない

  3. 失敗した脱出の試みの後に統合に閉じ込められるリスクです.そのようなケースでは損失を削減することは困難です.

  4. 幅広くストップ損失範囲は 時に大きな損失を意味します

リスクを減らすために

  1. ギャップバーと収集バーの識別のパラメータを最適化する.

  2. ポジションを入力する前に確認バーなどのフィルターを追加します.

  3. ストップ損失アルゴリズムを最適化して 適応性を高めます

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

主な最適化方向:

  1. 複合フィルターを加えると,誤ったブレイクを避けるため,例えば容量の増加が必要となる.

  2. 移動平均値と組み合わせて, MA のキーレベルが破られたときにのみ信号を取ります.

  3. 取引をする前に複数の時間枠で合意を要求する.

  4. 市場変動とリスク優先順位に基づいて,収益目標を動的に調整する.

  5. 市場体制識別システムと組み合わせ,トレンド環境での戦略のみを有効にします.

これらの最適化は安定性と収益性をさらに向上させることができる.

結論

3バーと4バーのブレイアウトリバーション戦略は,高品質のトレンド動きと逆転取引を捕捉することを目的としている.それは短い保持期間と高い頻度の利点がある.継続的な最適化によって削減する必要がある固有リスクもあります.原価行動から自立したトレンドと逆転信号を効果的に特定することで,この戦略はさらなる研究と適用を保証します.


/*backtest
start: 2023-12-10 00:00:00
end: 2023-12-17 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy(title="Three (3)-Bar and Four (4)-Bar Plays Strategy", shorttitle="Three (3)-Bar and Four (4)-Bar Plays Strategy", overlay=true, calc_on_every_tick=true, currency=currency.USD, default_qty_value=1.0,initial_capital=30000.00,default_qty_type=strategy.percent_of_equity)

frommonth = input(defval = 1, minval = 01, maxval = 12, title = "From Month")
fromday = input(defval = 1, minval = 01, maxval = 31, title = "From day")
fromyear = input(defval = 2021, minval = 1900, maxval = 2100, title = "From Year")

tomonth = input(defval = 12, minval = 01, maxval = 12, title = "To Month")
today = input(defval = 31, minval = 01, maxval = 31, title = "To day")
toyear = input(defval = 2100, minval = 1900, maxval = 2100, title = "To Year")

garBarSetting1 = input(defval = 1.5, minval = 0.0, maxval = 100.0, title = "Gap Bar Size", type = input.float)
garBarSetting2 = input(defval = 0.65, minval = 0.0, maxval = 100.0, title = "Gap Bar Body Size", type = input.float)
TopSetting = input(defval = 0.10, minval = 0.0, maxval = 100.0, title = "Bull Top Bar Size", type = input.float)

profitMultiplier = input(defval = 2.0, minval = 1.0, maxval = 100.0, title = "Profit Multiplier", type = input.float)

// ========== 3-Bar and 4-Bar Play Setup ==========
barSize = abs(high - low)
bodySize = abs(open - close)

gapBar = (barSize > (atr(1000) * garBarSetting1)) and (bodySize >= (barSize * garBarSetting2))  // find a wide ranging bar that is more than 2.5x the size of the average bar size and body is at least 65% of bar size

bullTop = close > close[1] + barSize[1] * TopSetting ? false : true  // check if top of bar is relatively equal to top of the gap bar (first collecting bull bar)
bullTop2 = close > close[2] + barSize[2] * TopSetting ? false : true  // check if top of bar is relatively equal to top of the gap bar (first collecting bear bar)
bearTop = close < close[1] - barSize[1] * TopSetting ? false : true  // check if top of bar is relatively equal to top of the gap bar (second collecting bull bar)
bearTop2 = close < close[2] - barSize[2] * TopSetting ? false : true  // check if top of bar is relatively equal to top of the gap bar (second collecting bear bar)

collectingBarBull = barSize < barSize[1] / 2 and low > close[1] - barSize[1] / 2 and bullTop  // find a collecting bull bar
collectingBarBear = barSize < barSize[1] / 2 and high < close[1] + barSize[1] / 2 and bearTop  // find a collecting bear bar
collectingBarBull2 = barSize < barSize[2] / 2 and low > close[2] - barSize[2] / 2 and bullTop2  // find a second collecting bull bar
collectingBarBear2 = barSize < barSize[2] / 2 and high < close[2] + barSize[2] / 2 and bearTop2  // find a second collecting bear bar

triggerThreeBarBull = close > close[1] and close > close[2] and high > high[1] and high > high[2]  // find a bull trigger bar in a 3 bar play
triggerThreeBarBear = close < close[1] and close < close[2] and high < high[1] and high < high[2]  // find a bear trigger bar in a 3 bar play
triggerFourBarBull = close > close[1] and close > close[2] and close > close[3] and high > high[1] and high > high[2] and high > high[3]  // find a bull trigger bar in a 4 bar play
triggerFourBarBear = close < close[1] and close < close[2] and close < close[3] and high < high[1] and high < high[2] and high < high[3]  // find a bear trigger bar in a 4 bar play

threeBarSetupBull = gapBar[2] and collectingBarBull[1] and triggerThreeBarBull  // find 3-bar Bull Setup
threeBarSetupBear = gapBar[2] and collectingBarBear[1] and triggerThreeBarBear  // find 3-bar Bear Setup
fourBarSetupBull = gapBar[3] and collectingBarBull[2] and 
   collectingBarBull2[1] and triggerFourBarBull  // find 4-bar Bull Setup
fourBarSetupBear = gapBar[3] and collectingBarBear[2] and 
   collectingBarBear2[1] and triggerFourBarBear  // find 4-bar Bear Setup

labels = input(title="Show Buy/Sell Labels?", type=input.bool, defval=true)

plotshape(threeBarSetupBull and labels, title="3-Bar Bull", text="3-Bar Play", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
plotshape(threeBarSetupBear and labels, text="3-Bar Bear", title="3-Bar Play", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
plotshape(fourBarSetupBull and labels, title="4-Bar Bull", text="4-Bar Play", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
plotshape(fourBarSetupBear and labels, text="4-Bar Bear", title="4-Bar Play", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.red, textcolor=color.white, transp=0)

alertcondition(threeBarSetupBull or threeBarSetupBear or fourBarSetupBull or fourBarSetupBear, title="3-bar or 4-bar Play", message="Potential 3-bar or 4-bar Play")
float sl = na
float tp = na
sl := nz(sl[1], 0.0)
tp := nz(tp[1], 0.0)
plot(sl==0.0?na:sl,title='SL', color = color.red)
plot(tp==0.0?na:tp,title='TP', color = color.green)
if (true)
    if threeBarSetupBull and strategy.position_size <=0
        strategy.entry("3 Bar Long", strategy.long, when=threeBarSetupBull)
        sl :=low[1]
    if threeBarSetupBear and strategy.position_size >=0
        strategy.entry("3 Bar Short", strategy.short, when=threeBarSetupBull)
        sl :=high[1]
    if fourBarSetupBull and strategy.position_size <=0
        strategy.entry("4 Bar Long", strategy.long, when=fourBarSetupBull)
        sl :=min(low[1], low[2])
    if fourBarSetupBear and strategy.position_size >=0
        strategy.entry("4 Bar Short", strategy.short, when=fourBarSetupBear)
        sl :=max(high[1], high[2])

if sl !=0.0
    if strategy.position_size > 0
        tp := strategy.position_avg_price + ((strategy.position_avg_price - sl) * profitMultiplier)
        strategy.exit(id="Exit", limit=tp, stop=sl)

    if strategy.position_size < 0
        tp := strategy.position_avg_price - ((sl - strategy.position_avg_price) * profitMultiplier)
        strategy.exit(id="Exit", limit=tp, stop=sl)

もっと