3つまたは4つのKライン突破反転戦略


作成日: 2023-12-18 10:39:53 最終変更日: 2023-12-18 10:39:53
コピー: 2 クリック数: 810
1
フォロー
1621
フォロワー

3つまたは4つのKライン突破反転戦略

概要

三四K線突破逆転戦略は,K線上での上昇勢いの大きい3つのK線または4つのK線を識別し,その後のより小さな幅のK線がサポートまたは圧力を形成した後,逆転K線が発生したときに逆転取引を行う.逆転取引戦略に属します.

戦略原則

この戦略の核となる識別論理は以下の部分で構成されています.

  1. 大幅に上昇したK線 ((Gap Bar) を識別する:平均ATRの1.5倍を突破し,实体部分は0.65より大きい.このK線は,より強い下落の勢いを持っていると考えられる.

  2. 縮小したK線を識別する ((Collecting Bar):Gap Barの1~2桁の小さな波動のK線に続いて,高点または低点がGap Barに近い.これらのK線は,トレンドの減速と収束を象徴し,サポートまたは圧力を形成する.

  3. 逆転信号K線を識別する.K線を整合した後に,ある実体が前幾つのK線の高点または低点のK線を突破した場合は,逆転信号とみなし,実体方向によって多行または空行を判断し,そのK線でポジションを開く.

  4. 止損とストップ:止損はGap Kラインの低点以下または高点の上部に設定される.ストップは,ストップポイントを配置した損失比率で掛けます.

優位分析

この戦略には以下の利点があります.

  1. K線そのものの特性を利用してトレンドと逆転点を判断し,いかなる指標にも依存せず,指数自帯を実現した.

  2. Gap BarとCollecting Barは厳格なフィルタリング条件で,実際のトレンドと整理を効果的に識別できます.

  3. 反転信号判断は実体準拠で,偽信号の確率を減らす.

  4. K線の組み合わせは3~4つで,取引が完了し,周期が短く,頻度が高くなります.

  5. ストップ・ストップ・ロスの設定は明確で,撤回と儲け損益比は簡単に制御できる.

リスク分析

この戦略には以下のリスクがあります.

  1. パラメータ設定の質に依存し,パラメータ設定が過度に緩やかであれば,偽信号と損金取引の機会が増加する.

  2. 高周波偽突破に容易な干渉で,偽信号をすべて効果的にフィルターすることはできません.

  3. 巻き込まれる危険性があり,逆転が不十分であれば,調整が容易になり,損が止まらない.

  4. ストップダストの範囲は大きいので,個別にセットされたチャンスで大きな損失が生じることがあります.

これらのリスクを低減するために,以下のような方法で最適化できます.

  1. パラメータを最適化して,Gap BarとCollecting Barの識別をより正確にします.

  2. フィルターを追加し,反転K線が再確認された後に開設する.

  3. ストップ・ロスのアルゴリズムを最適化して,ストップ・ロスを価格に近いものにし,損失を制御できるようにする.

最適化の方向

この戦略には,以下の主要な改善策があります.

  1. 複合フィルターを追加し,偽突破干渉を回避する.例えば,取引量指標を追加し,取引量が大きくなった場合にのみ取引信号を考慮する.

  2. 均線指数と組み合わせて,価格が重要な均線 (例えば20日線,60日線) を破るときのみ取引シグナルを考慮する.

  3. 複数のタイムフレームの検証で,複数の周期が同時に信号を与える時にのみポジションを開く.

  4. ストップ条件を最適化し,市場変動やリスク偏好の動向に応じて利益率を動的に調整する.

  5. 市場空白の判断システムと組み合わせたこの戦略は,トレンドの市場環境でのみ使用されます.

これらの最適化により,戦略の安定性と収益性の向上がさらに可能になる.

要約する

三四K線突破逆転戦略は,高品質のトレンドポテンシャル段と逆転シグナルを識別して取引する. 操作周期は短く,頻度が高い. 豊富な余分な利益を得る見込みがある. 同時に,一定のリスクも存在し,リスクを下げるため安定性を高めるために引き続き最適化する必要がある. 全体として,この戦略は,トレンド判断と逆転の特徴的なトレンドと逆転点を効果的に利用し,さらなる研究と応用に値する.

ストラテジーソースコード
/*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)