この戦略の核心的な考え方は,内含周期間のK線形状を利用してトレンドの方向を決定し,これを入場信号として使うことです. 前回のK線を含む内含周期間の形状が生じるとき,当時はトレンド転換の瞬間であると推論することができ,このとき,突破する前の高点で多めにするか,あるいは突破する前の低点で空にして,ストップと損失を設定することができます.
含有周期間のK線形が発生するかどうかを判断する.具体的判断の論理は,現在のK線の高点は前回のK線の高点より低い,そして現在のK線低点は前回のK線低点より高いである.
前K線の値判断. 閉盘価格が開盘価格より高い場合は値; 閉盘価格が開盘価格より低い場合は値.
前K線が上昇し,内在の周期間の形状が発生した場合は,前K線高点の10%範囲で買取停止命令を設定します.
前K線が下落し,内在周期間の形が起こると,前K線の低点の10%の範囲でストップを設定します.
ストップ・シートがポジション形成に触発されると,ストップ・スロー・シートとストップ・ストップ・シートを設定します. 特定のストップ・距離とストップ・距離は,前K線振幅の一定比率です.
また,内在周期間の形が再現された場合,優先的に平定し,新しい掛札を再設定します.
この戦略の利点は
K線内部の論理を用いて,入場時刻を正確に把握する.周期間の内在の形状は,傾向の逆転や加速が迫っていることを意味し,入場時刻を優遇する.
戦略のルールは明確で分かりやすく,実践的に操作しやすい.
前回のサイクルの高低点を利用してストップ・ストップの位置を設定することで,リスクをコントロールできます.
ランキングの順番が変われば,新しいランキングを設定し,新しいトレンドをたどることができます.
この戦略にはいくつかのリスクがあります.
周期間の形状は必ずしもトレンドの反転や加速を引き起こすわけではないので,偽信号のリスクがある.
ストップダメージ距離が小さすぎて,大きな振動に耐えられないかもしれない.
ストップ距離が大きすぎると,当時に利益を得られなくなります.
この戦略は,トレンドに依存し,トレンドを整合する際の利得の余地が限られている.
取引の頻度が高く,取引コストが高くなる可能性があります.
対策として
他の指標フィルターに含まれる周期間の形状の確認信号を組み合わせて,偽信号率を下げることができる.
止損距離を適正に緩めることができますが,前K線振幅の50%を超えてはいけません.
前K線振幅の約50%まで短縮することができる.
資金管理を最適化し,単一ポジションを削減し,整合状況に対応する.
取引を制限する条件を適切に緩和する
この戦略は,以下の点で最適化できます.
トレンド指数と組み合わせてトレンドの方向を判断し,清算時に頻繁に取引を避ける.例えば,MACDの判断トレンドに加入し,MACDが同方向の時にのみ入場を検討する.
利害を抑える戦略を最適化し,移動式止損または利潤保護止損などの方法で止損をより弾力的にします.
異なるストップ・ストップ比率の設定をテストして,最適なパラメータの組み合わせを見つけます.
再び入場するメカニズムは, 止損退出後に再びトレンドを捉えるためのものです.
ポジション管理の最適化,市場の変動に応じて単位のポジションの調整.
固定資金利用率などの資金管理の最適化
この戦略の効果を様々な品種と時間周期でテストする.
概して述べると,これは,周期間の内在の形状判断トレンドの転換点を利用して,反転トレンドを捕捉するための挂牌を設定する戦略である.それは,入場時刻の明確性,戦略規則の簡素性,制御可能なリスクなどの利点を持っているが,一定の偽信号リスクと最適化スペースもある.我々は,トレンド指標,停止損失の停止値の最適化,ポジションの調整などの方法で戦略の安定性と収益性をさらに向上させることができる.この戦略は,トレンド性のある状況に適している.具体的運用では,市場の異なる特性を対象に最適化テストを行う必要があり,その最大限の効果を発揮する.
/*backtest
start: 2023-01-01 00:00:00
end: 2023-03-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
// Inside Bar Momentum Strategy
// As defined on Babypips.com
// https://www.babypips.com/trading/forex-inside-bar-20170113
// strategy("Babypips: Inside Bar Momentum Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5)
From_Year = input(defval = 2018, title = "From Year")
From_Month = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
From_Day = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
To_Year = input(defval = 9999, title = "To Year")
To_Month = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
To_Day = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
Start = timestamp(From_Year, From_Month, From_Day, 00, 00) // backtest start window
Finish = timestamp(To_Year, To_Month, To_Day, 23, 59) // backtest finish window
Window = true
Stop_Buy_Perc = input(10, "Stop Buy Order Percentage From Previous Candle's Range")/100
Stop_Loss_Perc = input(20, "Stop Loss Distance from High/Low of Previous Candle")/100
Take_Prof_Perc = input(80, "Take Profit Distance from High/Low of Previous Candle")/100
Risk = input(2, "Percentage Of EQUITY to risk per trade", step=0.1, minval=0, maxval=100)/100
Inside_Bar = high[1] > high[0] and low[1] < low[0]
Prev_Range = high[1] - low[1]
Bullish = open[1] < close[1]
Bearish = open[1] > close[1]
// Get Key Levels
Long_Stop_Buy_Level = high[1] + (Prev_Range * Stop_Buy_Perc)
Short_Stop_Buy_Level = low[1] - (Prev_Range * Stop_Buy_Perc)
Long_Stop_Loss_Level = high[1] - (Prev_Range * Stop_Loss_Perc)
Short_Stop_Loss_Level = low[1] + (Prev_Range * Stop_Loss_Perc)
Long_Take_Prof_Level = high[1] + (Prev_Range * Take_Prof_Perc)
Short_Take_Prof_Level = low[1] - (Prev_Range * Take_Prof_Perc)
// Position Sizing
long_qty = floor((strategy.equity * Risk) / (Long_Stop_Buy_Level - Long_Stop_Loss_Level))
short_qty = floor((strategy.equity * Risk) / (Short_Stop_Loss_Level - Short_Stop_Buy_Level))
// -------------------------- LONG CONDITIONS --------------------------------//
// The first candlestick must be bullish (green or white) and if the second
// candlestick is completely contained by the first, set a buy stop order at
// the first candle’s high plus 10% of its range (high minus low).
// Place the stop loss at the first candle’s high minus 20% of its range
// and set the target at the first candle’s high plus 80% of its range
// If another inside bar pattern forms, the current position should be closed
// or the pending buy/sell order must be canceled and entry orders must be
// updated to the latest candles.
Long_Condition = Window and Inside_Bar and Bullish
if (Long_Condition)
// Incase we still have a buy stop order in the market
strategy.cancel_all()
// Close any existing positions according to the rules
strategy.close_all()
strategy.entry("Bullish IB", strategy.long, stop=Long_Stop_Buy_Level)
strategy.exit("Bullish Exit","Bullish IB", stop=Long_Stop_Loss_Level, limit=Long_Take_Prof_Level)
// -------------------------- SHORT CONDITIONS -------------------------------//
// The first candlestick must be bearish (red or black) and if the second
// candlestick is completely contained by the first, set a sell stop order at
// the first candle’s low minus 10% of its range (high minus low).
// Place the stop loss at the first candle’s low plus 20% of its range and
// set the target at the first candle’s low minus 80% of its range.
// If another inside bar pattern forms, the current position should be closed
// or the pending buy/sell order must be canceled and entry orders must be
// updated to the latest candles.
Short_Condition = Window and Inside_Bar and Bearish
if (Short_Condition)
// Incase we still have a buy stop order in the market
strategy.cancel_all()
// Close any existing positions according to the rules
strategy.close_all()
strategy.entry("Bearish IB", strategy.short, stop=Short_Stop_Buy_Level)
strategy.exit("Bearish Exit","Bearish IB", stop=Short_Stop_Loss_Level, limit=Short_Take_Prof_Level)
// ----------------------------- PLOTTING ------------------------------------//
plotshape(Inside_Bar, style=shape.arrowdown, location=location.abovebar, color=purple)