세 바와 네 바 브레이크업 역전 전략

저자:차오장, 날짜: 2023-12-18 10:39:53
태그:

img

전반적인 설명

세 바와 네 바 브레이크아웃 리버션 전략은 강한 추진력을 가진 세 개 또는 네 개의 K 라인 바를 식별하고 여러 개의 작은 범위의 K 바가 지원 / 저항 수준을 형성하고 반전 신호가 나타났을 때 역동 트렌드를 취합니다. 그것은 평균 리버션 전략에 속합니다.

전략 논리

이 전략의 핵심 식별 논리는 다음을 포함합니다.

  1. 장거리 바 (Gap Bars) 를 인식한다: 1.5 x ATR, 몸의 비율이 65% 이상인 파업. 그들은 강한 추진력을 가지고 있다고 간주된다.

  2. 낮은 범위의 바를 인식 (집집합 바): 한 또는 두 개의 후속의 작은 범위의 바가 간격 바에 따라, 간격 바의 수준에 가까운 높은 / 낮은 수준. 그들은 지지 / 저항 수준을 형성하는 둔화 추진력과 통합을 나타냅니다.

  3. 반전 신호 바를 인식: 만약 바가 통합 후 이전 바의 높은/하위를 깨면, 반전 신호로 간주 될 수 있습니다. 우리는 신호 바의 방향에 따라 위치를 취합니다.

  4. 스톱 로스 및 영업 영업: 스톱 로스를 바의 낮은/높은 지점 아래/높이에 설정한다. 영업 영업은 스톱 로스 거리와 리스크 리워드 비율을 곱하여 결정된다.

이점 분석

이 전략의 주요 장점:

  1. 추세와 반전을 파악하기 위해 원시 가격 동작을 사용해야 합니다. 지표가 필요하지 않습니다.

  2. 격차 바와 수집 바에 대한 엄격한 규칙은 실제 추세와 통합에 대한 정확성을 보장합니다.

  3. 반전 바를 몸으로 판단하면 잘못된 신호를 줄일 수 있습니다.

  4. 매 거래는 3-4번 정도만 걸립니다. 높은 주파수와 짧은 유지 기간이죠.

  5. 스톱 로즈와 수익을 취하기 위한 명확한 규칙은 위험 관리에 도움이 됩니다.

위험 분석

주요 위험은:

  1. 매개 변수 설정에 의존합니다. 느슨한 매개 변수는 잘못된 신호와 손실 거래를 증가시킵니다.

  2. 가짜 탈출에 취약하고 모든 잘못된 신호를 필터링할 수 없습니다.

  3. 실패한 탈출 시도 후 통합에 갇히는 위험이 있습니다. 그러한 경우 손실을 줄이는 것이 어렵습니다.

  4. 폭 넓은 스톱 손실 범위는 함락되었을 때 때때로 큰 손실을 의미합니다.

위험을 줄이기 위해:

  1. 간격 바와 수집 바 식별에 대한 매개 변수를 최적화합니다.

  2. 포지션을 입력하기 전에 확인 바와 같은 필터를 추가합니다.

  3. 스톱 로스 알고리즘을 최적화해서 좀 더 적응력을 갖도록

최적화 방향

주요 최적화 방향:

  1. 복합 필터를 추가하여 가짜 브레이크를 피하기 위해, 예를 들어 부피를 증가시키는 것을 요구합니다.

  2. 이동 평균과 결합하여 주요 MA 레벨이 깨지면 신호를 취합니다.

  3. 거래에 들어가기 전에 여러 시간 프레임에 대한 동의를 요구합니다.

  4. 시장 변동성과 위험 선호도에 따라 수익 목표를 동적으로 조정합니다.

  5. 시장 체제 식별 시스템과 결합, 트렌딩 환경에서 전략을 활성화합니다.

이러한 최적화는 안정성과 수익성을 더욱 향상시킬 수 있습니다.

결론

세 바와 네 바 브레이크아웃 리버션 전략은 고품질의 트렌드 움직임과 역전 거래를 포착하는 것을 목표로합니다. 짧은 보유 기간과 높은 빈도의 장점이 있습니다. 또한 지속적인 최적화를 통해 감소해야하는 내재적인 위험이 있습니다. 원시 가격 행동에서 자체 트렌드 및 역전 신호를 효과적으로 식별함으로써이 전략은 추가 연구와 응용을 보장합니다.


/*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)

더 많은