황소 깃발 탈출 전략

저자:차오장, 날짜: 2024-02-22 16:41:04
태그:

img

전반적인 설명

올 플래그 브레이크아웃 전략은 올 플래그 차트 패턴을 식별하고 브레이크아웃 지점에서 진입하는 기술 분석 전략으로, 트렌드의 시작을 파악하는 것을 목표로 한다. 이 전략은 명확한 플래그 폴트 이후 플래그 범위를 결정하는 데 도움을 주기 위해 평균 참 범위 (ATR) 지표를 사용하며 진입 기회를 필터링한다.

전략 논리

이 전략의 주요 단계는 다음과 같습니다.

  1. 플래그포스트를 결정합니다. 새로운 높은 가격과 ATR 채널의 브레이크가 필요합니다.
  2. 기둥 높이를 결정합니다. 기둥 꼭대기와 이전 SMA 사이의 거리를 측정합니다.
  3. 플래그 범위를 결정합니다. 플래그 바닥은 가장 낮은 범위로 기둥 높이의 33%입니다.
  4. 플래그 패턴을 확인: 마지막 3 바가 플래그 범위 안에 있는지 판단합니다.
  5. 입력: 깃발 패턴이 나타났을 때 길게 이동합니다.
  6. 출구: 고정된 6 바 후에 닫기

플래그와 플래그를 판단할 때 전략은 ATR 지표를 현명하게 사용하여 중요한 브레이크오프를 결정하고 과도한 잘못된 신호를 피하기 위해 플래그 높이의 33% 내에서 플래그 높이를 엄격히 제한합니다. 또한 플래그를 형성하기 위해 3 개의 연속 바를 요구하면 신뢰성이 향상됩니다. 전반적으로 전략 규칙은 엄격하게 설계되어 초기 트렌드 브레이크오프를 캡처하는 데 약간의 이점이 있습니다.

이점 분석

이 전략의 주요 장점은 다음과 같습니다.

  1. 플래그 패턴을 사용하여 트렌드 시작을 결정하는 것은 높은 성공률을 가진 고전적인 기술 분석 방법입니다.
  2. ATR 및 엄격한 범위 제한은 많은 잘못된 신호를 피하고 입력 정확도를 향상시킵니다.
  3. 일부 수익에 6 바 출구 잠금 고정 및 반전 위험을 피합니다.
  4. 명확하고 적용하기 쉽고 이해하기 쉬운 규칙.
  5. 다양한 시장 조건에서 기회를 찾을 수 있고 유연합니다.

위험 분석

이 전략의 주요 위험은 다음과 같습니다.

  1. 플래그는 트렌드를 완전히 결정할 수 없습니다. 실패는 여전히 존재합니다.
  2. 6 바 출입은 조기 및 출입은 너무 일찍 될 수 있습니다.
  3. 시장의 혼란은 쉽게 가짜 깃발을 만들 수 있습니다.
  4. 단일 손실 금액을 효과적으로 통제할 수 없습니다.

위의 위험을 해결하기 위해, 우리는 중지 손실을 설정 할 수 있습니다. 특정 이익 비율에 도달 할 때 이익을 잠금하기 위해 출구 메커니즘을 최적화 할 수 있습니다. 우리는 또한 불안정한 시장에서 잘못된 신호를 피하기 위해 다른 지표로 필터링 할 수 있습니다.

최적화 방향

전략을 최적화하는 몇 가지 방향:

  1. MACD와 KD와 같은 지표를 결합하여 불운한 시장에서 잘못된 신호를 피합니다.
  2. 적응력을 향상시키기 위해 시장 체제에 기반한 ATR 곱셈, 출구 기간을 매개 변수화합니다.
  3. 트레일링 스톱 로스를 설정하거나 동적 출구에 대한 수익 인출 비율을 고려하십시오.
  4. 깃발 높이를 결정하는 더 나은 특징을 찾기 위해 기계 학습 접근법을 시도하십시오.
  5. 실제 승률과 수익률을 평가하고, 역동적으로 포지션 크기를 조정합니다.

결론

결론적으로, 황소 깃발 브레이크아웃 전략은 트렌드 시작을 결정하기 위해 기술적 패턴을 활용하고, 상당히 고전적인 방법이며, 진입 규칙은 실제로 많은 잘못된 신호를 필터링하기 위해 엄격하게 설계되었습니다. 그러나 충분한 검증과 최적화 후에 전략이 다른 시장에서 안정적으로 작동 할 수 있도록 위험 통제 및 전체적으로 출출을 개선 할 여지가 있습니다. 양적 거래 시스템의 귀중한 구성 요소가 될 수 있습니다.


/*backtest
start: 2024-01-22 00:00:00
end: 2024-02-21 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © smith26
//This strategy enters on a bull flag and closes position 6 bars later.  Average true range is used instead of a moving average.
//The reason for ATR instead of MA is because with volatile securities, the flagpole must stand up a noticable "distance" above the trading range---which you can't determine with a MA alone.
//This is broken up into multiple parts: Defining a flagpole, defining the pole height, and defining the flag, which will be constrained to the top third (33%) of the pole height to be considered a flag.
//@version=4
strategy("Bull Flag v1.00", overlay=true)

ATR = atr(10) //Average True Range over last 10 bars.

upperATR = ohlc4[1] + ATR[1]  //Open + High + Low + Close divided by 4, + prior ATR.  Just used here for visually plotting the ATR upper channel.
lowerATR = ohlc4[1] - ATR[1] //Open + High + Low + Close divided by 4, - prior ATR.  Just used here for visually plotting the ATR lower channel.

//uncomment these two lines to see ATR channels
plot(upperATR, color=color.orange)
plot (lowerATR, color=color.orange)

//Current close higher than previous close, and current close minus current open is greater than 3 times the previous ATR.  "3x ATR" is chosen because any less was not a noticeable distance above the trading range.
flagpole1 = close>close[1] and (close-open) > (ATR[1] * 3)
plotshape(flagpole1, text="flagpole1", style=shape.arrowdown, size=size.huge) //Plots an arrow for flagpole1 for QA testing

//Two consecutive close higer than their previous close, and current close minus PREVIOUS open is greater than 3 times the previous ATR.
flagpole2 = close>close[1] and close[1]>close[2] and (close-open[1]) > (ATR[1] * 3)
plotshape(flagpole2, text="flagpole2", style=shape.arrowdown, size=size.huge, color=color.yellow) //Plots an arrow for flagpole2 for QA testing

//Three consecutive close higer than their previous close, and current close minus open from 2 bars ago is greater than 3 times the previous ATR.
flagpole3 = close>close[1] and close[1]>close[2] and close[2]>close[3] and (close-open[2]) > (ATR[1] * 3)
plotshape(flagpole3, text="flagpole3", style=shape.arrowdown, size=size.huge, color=color.white) //Plots an arrow for flagpole3 for QA testing

//A flagpole can be any of the three definitions of flagpole.
flagpole = flagpole1 or flagpole2 or flagpole3

//This will return the number of bars since "flagpole" was true.  Not being used, but could be useful.
//since_flagpole = barssince(flagpole)

after_pole_1 = flagpole[1] //This marks the bar directly after a flagpole.  
//plotshape(after_pole_1, text="after_pole_1", style=shape.cross, size=size.large, color=color.white) //Plots a cross for after_pole_1 for QA testing
after_pole_2 = flagpole[2] //This marks the bar two bars after a flagpole.  
after_pole_3 = flagpole[3] //This marks the bar three bars after a flagpole.  

//This returns the price at the "top" of the flagpole (using close price) at the most recent occurence, 0.
pole_top = valuewhen(flagpole, close, 0)
//plot(pole_top, trackprice=true)  //plots a horizontal line at the most recent pole_top

//Measures the distance between last pole top and the previous SMA.
pole_height = pole_top - sma(close, 10)[1] 
//plot(pole_height)

//This marks 33% below the pole_top, which will be the lowest point a flag can be.
flag_bottom = pole_top - (.33 * pole_height)
//plot(flag_bottom)

//The first, second, and third bars after the pole are considered part of a flag when open and close are between the pole_top and flag_bottom
flag1 = after_pole_1 and (open >= flag_bottom) and (open <= pole_top) and (close >= flag_bottom) and (close <= pole_top)
//plotshape(flag1, text="flag1", style=shape.flag, size=size.large, color=color.teal)
flag2 = after_pole_2 and (open >= flag_bottom) and (open <= pole_top) and (close >= flag_bottom) and (close <= pole_top)
//plotshape(flag2, text="flag2", style=shape.flag, size=size.large, color=color.teal)
flag3 = after_pole_3 and (open >= flag_bottom) and (open <= pole_top) and (close >= flag_bottom) and (close <= pole_top)
//plotshape(flag3, text="flag3", style=shape.flag, size=size.large, color=color.teal)

//When all three bars after a flagpole are a flag, the criteria are met and we have a "bull_flag"
//Specifically, when current bar is flag3, previous bar is flag2, and 2 bars ago is flag1, we have a bull_flag.
bull_flag = flag3 and flag2[1] and flag1[2]
plotshape(bull_flag, text="bull_flag", style=shape.flag, size=size.large, color=color.white) //Plots a flag for bull_flag for QA testing


if (bull_flag)
    strategy.entry("Long", strategy.long)

if barssince(bull_flag) == 6 //close 6 bars after entry.
    strategy.close("Long")

더 많은