3~4개의 K라인 돌파 반전 전략


생성 날짜: 2023-12-18 10:39:53 마지막으로 수정됨: 2023-12-18 10:39:53
복사: 2 클릭수: 808
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

3~4개의 K라인 돌파 반전 전략

개요

3~4K선 돌파 반전 전략은 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. 단 3~4개의 K선 조합으로 하나의 거래를 완료할 수 있으며, 시간주기는 짧고, 빈도는 높다.

  5. 정지/손실 설정이 명확하고, 회수/손실 비율이 제어하기 쉽다.

위험 분석

이 전략에는 다음과 같은 위험도 있습니다.

  1. 매개 변수 설정의 질에 따라 달라집니다. 매개 변수 설정이 너무 느슨하면 가짜 신호와 돈을 잃는 거래의 기회가 증가합니다.

  2. 높은 주파수 가짜 돌파구에 의해 방해가 될 수 있으며, 모든 가짜 신호를 효과적으로 필터링 할 수 없습니다.

  3. 하지만, 만약 회전이 부족하면, 손해가 막히지 않을 수 있습니다.

  4. 스톱 손실 범위가 넓고, 개별적으로 피팅된 기회는 큰 손실을 초래할 수 있다.

이러한 위험을 줄이기 위해, 다음과 같은 몇 가지 측면에서 최적화할 수 있습니다.

  1. 개정된 매개 변수를 사용하여 Gap Bar와 Collecting Bar를 더 정확하게 식별할 수 있습니다.

  2. 필터를 추가하고, 반전 K 라인을 다시 확인한 후 포지션을 열습니다.

  3. 스톱로스 알고리즘을 최적화하여 스톱로스를 가격에 더 가깝게 하고 손실을 더 통제할 수 있게 한다.

최적화 방향

이 전략에는 다음과 같은 몇 가지 주요 개선방향이 있습니다.

  1. 복합 필터를 추가하여 가짜 돌파구 간섭을 방지한다. 예를 들어 거래량 지표를 추가하여 거래량이 커지면 거래 신호를 고려한다.

  2. 평준선 지표와 결합하여, 가격이 중요한 평준선을 돌파했을 때만 거래 신호를 고려한다 (예: 20 일선, 60 일선).

  3. 다중 시간 프레임 검증, 여러 주기 동시에 신호를 줄 때만 포지션을 열 수 있다.

  4. 시장의 변동성과 위험 선호도에 따라 수익/손실 비율을 동적으로 조정하는 최적화 된 차단 조건.

  5. 시장의 빈 상태 판단 시스템과 결합하여, 트렌딩 시장 환경에서만 이 전략을 사용한다.

이러한 최적화는 전략의 안정성과 수익률을 더욱 높일 수 있습니다.

요약하다

3-4K선 돌파 반전 전략은 고품질의 트렌드 잠재적인 부분과 반전 신호를 식별하여 거래한다. 운영주기는 짧고, 주파수가 높으며, 풍부한 초과 수익을 얻을 수 있다. 또한 위험도 존재하며, 위험을 낮추고 안정성을 높이기 위해 계속 최적화해야 한다.

전략 소스 코드
/*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)