고/저 전략의 실패

저자:차오장, 날짜: 2023-12-22 12:59:43
태그:

img

전반적인 설명

브로킹 하이/로 전략은 트렌드를 따르는 전략으로, 이전 촛불의 최고 또는 최저 이상의 가격 브레이크를 추적합니다. 트렌드 방향을 결정하기 위해 이동 평균을 사용하여 브레이크 포인트에 입력하고, 수익을 잠금하기 위해 스톱 로스 또는 트레일링 스톱 로스를 사용합니다.

전략 논리

이 전략에 의해 결정되는 입국 및 출국 주요 조건은 다음과 같습니다.

  1. 촛불이 녹색 또는 빨간색인지 확인 하 여 촛불 위 또는 아래를 결정
  2. 현재 촛불이 이전 촛불의 높은 또는 낮은 깨는지 확인
  3. 트렌드 방향을 정의하기 위해 빠르고 느린 이동 평균을 사용
  4. 상향 촛불이 이전 상향 촛불의 최고보다 높을 때 길게, 상향 촛불이 이전 상향 촛불의 최저보다 낮을 때 짧게
  5. 출구 조건은 스톱 로스 또는 트레일링 스톱에 의해 유발됩니다. 반전 촛불이 나타나면 즉시 출구 할 수도 있습니다.

이 전략은 또한 가짜 브레이크를 방지하고 신호 신뢰성을 보장하기 위해 두 번째 역전 촛불에 기반한 필터를 사용합니다.

이점 분석

  • 명확한 전략 지향, 쉽게 이해 할 수 있는 탈출 작전
  • 두 개의 이동 평균을 결합하여 올바른 트렌드 판단을 보장합니다.
  • 트레일링 스톱은 더 많은 수익을 확보하는 데 도움이 됩니다.
  • 반전 촛불 필터는 높은 것을 추구하고 낮은 것을 죽이는 것을 피하는 데 도움이됩니다

위험 분석

  • 실패한 파업은 극히 짧은 기간의 거래에서 손실을 초래할 수 있습니다.
  • 범주형 시장에서 거짓 파업 위험이 더 높습니다
  • 이중 이동 평균은 판단 오류로 이어지는 지연이 발생할 수 있습니다.

위험 관리 조치:

  1. 개별 주식의 높은 위험을 피하기 위해 인덱스 또는 주요 벤치마크를 선택하십시오.
  2. 판단 정확성을 향상시키기 위해 이동 평균 매개 변수를 최적화
  3. 단일 거래 손실을 통제하기 위해 정지 손실 범위를 합리적으로 확장하십시오.

최적화 방향

이 전략은 다음과 같은 측면에서 최적화 될 수 있습니다.

  1. 이동 평균 매개 변수의 다른 조합을 테스트합니다.
  2. 콤보 판단을 위한 다른 기술적 지표를 포함하는 시험
  3. 입력 및 중지 손실 레벨의 매개 변수를 최적화
  4. 고품질 기반을 선택하기 위해 양적 필터링 규칙을 추가
  5. 적응적 매개 변수 최적화를 위한 기계 학습 알고리즘을 통합

요약

브로큰 하이/로 전략은 전반적으로 성숙한 트렌드 추후 전략이다. 보조 판단을 위해 이동 평균의 도움으로 특정 수준의 트렌드를 파악할 수 있다. 스톱 로스 및 트레일링 스톱 메커니즘은 또한 수익을 잠금하는 데 도움이 된다. 지속적인 테스트와 최적화를 통해 이 전략의 매개 변수와 성능이 더 뛰어난 것이 될 수 있다.


/*backtest
start: 2022-12-15 00:00:00
end: 2023-12-21 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Broken High/Low Strategy", overlay=true, initial_capital = 5000, default_qty_value = 25, pyramiding = 10, default_qty_type= strategy.percent_of_equity)

useEMAForStop = input.bool(false, 'Use trail stop EMA', group = 'Exit strategy')
trailStopMALength = input(8, 'Trail stop EMA length', group = 'Exit strategy')

fastMALength = input(5 , 'Fast MA length', group = 'Trend strength')
fastEMAEnabled = input.bool(false, 'Fast EMA enabled (default is SMA)', group = 'Trend strength')

slowMALength = input(10, 'Slow MA length', group = 'Trend strength')
slowEMAEnabled = input.bool(false, 'Slow EMA enabled (default is SMA)', group = 'Trend strength')

ignoreSlowMA = input.bool(false, 'Use fast MA for trend ignoring slow MA', group = 'Trend strength')

useOpposingBarAsExit = input.bool(false, 'Using opposing bar as exit', group = 'Exit strategy')
secondEntryEnabled = input.bool(false, 'Second bar that eliminates opposing bar for entry', group = 'Trend strength')

longsEnabled = input.bool(true, 'Enable longs', group = 'Trade settings')
shortsEnabled = input.bool(true, 'Enable shorts', group = 'Trade settings')

fastMA = fastEMAEnabled ? ta.ema(close, fastMALength) : ta.sma(close, fastMALength)
slowMA = slowEMAEnabled ? ta.ema(close, slowMALength) : ta.sma(close, slowMALength)

FromMonth=input.int(defval=1,title="FromMonth",minval=1,maxval=12, group = 'Time filters')
FromDay=input.int(defval=1,title="FromDay",minval=1,maxval=31, group = 'Time filters')
FromYear=input.int(defval=1990,title="FromYear",minval=1900, group = 'Time filters')
ToMonth=input.int(defval=1,title="ToMonth",minval=1,maxval=12, group = 'Time filters')
ToDay=input.int(defval=1,title="ToDay",minval=1,maxval=31, group = 'Time filters')
ToYear=input.int(defval=9999,title="ToYear",minval=2017, group = 'Time filters')
start=timestamp(FromYear,FromMonth,FromDay,00,00)
finish=timestamp(ToYear,ToMonth,ToDay,23,59)
window()=>time>=start and time<=finish?true:false
afterStartDate = time >= start and time<=finish?true:false
closeTradesEOD = input.bool(false, 'Close trades end of day', group = 'Time filters')

trailStopMA = ta.ema(close, trailStopMALength)

isGreenCandle = close > open
isRedCandle = close < open
isBrokenHigh = close > open[1]
isPriorCandleRed = close[1] < open[1]
isPriorPriorCandleRed = close[2] < open[2]
isPriorPriorCandleGreen = close[2] > open[2]
isPriorCandleGreen = close[1] > open[1]
isBrokenLow = close < open[1]

isPriorRedCandleBroken = isGreenCandle and isPriorCandleRed and isBrokenHigh
isPriorGreenCandleBroken = isRedCandle and isPriorCandleGreen and isBrokenLow

isPriorPriorRedCandleBroken = secondEntryEnabled and not isPriorRedCandleBroken and isGreenCandle and isPriorPriorCandleRed ? close > open[2] : false
isPriorPriorGreenCandleBroken = secondEntryEnabled and not isPriorGreenCandleBroken and isRedCandle and isPriorPriorCandleGreen ? close < open[2] : false

longOpenCondition = (isPriorRedCandleBroken or isPriorPriorRedCandleBroken) and afterStartDate and (ignoreSlowMA ? close > fastMA : fastMA > slowMA) and longsEnabled
longCloseCondition = useOpposingBarAsExit ? isRedCandle : ta.crossunder(close, fastMA)
longCloseCondition := useEMAForStop ? ta.crossunder(close, trailStopMA) : longCloseCondition

shortOpenCondition = (isPriorGreenCandleBroken or isPriorPriorGreenCandleBroken) and afterStartDate and (ignoreSlowMA ? close < fastMA : fastMA < slowMA) and shortsEnabled
shortCloseCondition = useOpposingBarAsExit ? isGreenCandle : ta.crossover(close, fastMA)
shortCloseCondition := useEMAForStop ? ta.crossover(close, trailStopMA) : shortCloseCondition

if (longOpenCondition)
    strategy.entry("Long Entry", strategy.long)

if (longCloseCondition)
    strategy.close('Long Entry', 'Long Exit')

if (shortOpenCondition)
    strategy.entry("Short Entry", strategy.long)

if (shortCloseCondition)
    strategy.close('Short Entry', 'Short Exit')

if (closeTradesEOD and hour >= 14 and minute >= 30)
    strategy.close_all("EOD")

plot(useEMAForStop ? trailStopMA : na, linewidth = 2, color = color.red)
plot(fastMA)
plot(ignoreSlowMA ? na : slowMA, linewidth = 4)

더 많은