정확한 트렌드 브레이크 트레이딩 전략

저자:차오장, 날짜: 2023-11-02 16:26:22
태그:

img

전반적인 설명

정확한 트렌드 브레이크아웃 거래 전략은 트렌드 브레이크아웃을 정확하게 파악하기 위해 트렌드 지표와 특정 촛불 패턴을 사용합니다. 트렌드 방향을 결정하기 위해 이동 평균, 과잉 구매 및 과잉 판매 수준을 측정하기 위해 RSI 및 브레이크아웃 진입 지점을 파악하기 위해 고급 촛불 패턴을 결합하여 과도한 이익에 대한 적절한 순간에 브레이크아웃 거래를위한 정확한 트렌드 식별을 가능하게합니다.

전략 논리

  1. 트렌드 방향을 정의하기 위해 8주기 EMA와 80주기 EMA를 사용하십시오. 80주기 EMA 이상의 8주기 EMA는 상승 추세를 나타냅니다. 하락 추세를 나타냅니다. 트렌드 방향이 일치 할 때만 거래 신호를 고려하십시오.

  2. 촛불 1의 낮은 < 촛불 2의 낮은 및 촛불 3의 낮은 < 촛불 2의 낮은 특정 3 촛불 형성을 정의하십시오. 이 패턴은 상승 추세에 긴 입구를 신호하고 하락 추세에 짧은 입구를 신호합니다.

  3. 3번째 촛불은 앞의 촛불의 범위 내에서 닫기 가격을 형성하는 것이 최적의 진입 지점을 나타냅니다. 123 패턴은 바로 거래 주문을 발동합니다.

  4. 세 번째 촛불 높이에 장거리, 세 번째 촛불 낮에 단거리. 촛불 2의 낮은 (장거리) 또는 촛불 2의 높은 (단거리) 에서 손해를 중지하십시오. 2배의 위험에 수익을 취하십시오.

  5. 트렌드, 패턴, 지표가 높은 확률 무역에 동의 할 때 브레이크 오더를 배치하십시오. 견고한 브레이크 오더 접근을 위해 수익을 잠금하기 위해 손해를 멈추고 이익을 취하십시오.

이점 분석

이 전략은 다음과 같은 주요 장점을 가지고 있습니다.

  1. 이중 EMA는 트렌드에 반대하는 거래를 피하기 위해 전체 트렌드 방향을 정의합니다.

  2. 촛불 패턴은 높은 확률의 탈출 형태를 검사합니다.

  3. 트렌드, 패턴, 지표에 대한 합의는 신호 품질을 보장합니다.

  4. 내부 바는 신호 신뢰성을 향상시키고 입력 시기를 더욱 보장합니다.

  5. 미리 설정된 스톱 로스 및 취득은 개별 거래 위험을 관리합니다.

  6. 백테스트는 통계적 우위를 위해 65% 이상의 승률을 검증합니다.

요약하자면, 전략은 정확한 브레이크오웃 타이밍을 위해 종합적인 트렌드, 패턴 및 지표 분석을 활용하여 안정적인 리스크-어워드 어드 (risk-reward edge) 를 제공합니다.

위험 분석

주요 위험은 다음과 같습니다.

  1. 잘못된 트렌드 호출은 불안정한 조건에서 잘못된 신호를 생성합니다. 추가 트렌드 메트릭은 확인을 향상시킬 수 있습니다.

  2. 정적 스톱 로스/프로프트 취업은 모든 가격 변동에 완벽하게 맞지 않습니다. 적응 영역이 바람직할 수 있습니다.

  3. 촛불 패턴 인식은 광범위한 최적화를 요구하는 매개 변수 조정에 달려 있습니다.

  4. 블랙 스완 사건은 무역에 심각한 영향을 미치며 예측할 수 없습니다. 위험 통제를 위해 포지션 사이징이 권장됩니다.

  5. 백테스트 결과는 너무 적합하고 실시간 성능을 잘못 나타낼 수 있습니다. 매개 변수는 안정성 검증이 필요합니다.

  6. 더 높은 거래 빈도는 거래 비용을 증가시킵니다. 이긴 비율과 위험/이익 비율은 비용을 적절히 커버해야합니다.

적절한 매개 변수 최적화, 추가 신호 차원 및 위치 크기는 위험을 효과적으로 최소화하고 성능 일관성을 향상시킬 수 있습니다.

최적화 방향

주요 최적화 차원은 다음을 포함합니다.

  1. 더 큰 안정성을 위해 추가 촛불 기간 매개 변수를 테스트합니다.

  2. 부진을 방지하기 위해 부피 확인을 추가합니다.

  3. 매개 변수 안정성을 위한 샤프 비율과 같은 메트릭을 포함합니다.

  4. 통제된 동적 이득을 위한 수익 추적 메커니즘을 도입해야 합니다.

  5. VIX 공황 수준에 따라 신호를 필터하여 불확실성을 피합니다.

  6. 이상적인 거래 기간을 위해 보유 기간을 최적화하십시오.

  7. 정적 스톱을 넘어서 스톱 손실 메커니즘을 개선합니다.

이러한 조치는 전략의 안정성, 유연성 및 수익성을 더욱 향상시킬 수 있습니다.

결론

정확한 트렌드 브레이크아웃 트레이딩 전략은 높은 확률의 트렌드 브레이크아웃 포착을 위해 트렌드, 패턴, 스톱 로스/프로프트 분석을 성공적으로 결합합니다. 명확한 거래 신호, 강력한 지표 확인 및 제어 된 위험으로 트렌드 시장에 잘 맞는 효율적인 전략입니다. 지속적인 최적화 및 향상으로 전략은 트렌드 브레이크아웃 추적 및 위치 관리의 강력한 도구로 약속을 가지고 있으며, 큰 이익을 추구하는 거래자에게 엄청난 가치를 부여합니다.


/*backtest
start: 2022-11-01 00:00:00
end: 2023-10-14 05:20:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © julianossilva

//@version=5
strategy(title="J2S Backtest: 123-Stormer Strategy",
         shorttitle="J2S Backtest: 123-Stormer Strategy",
         overlay=true, initial_capital=1000, default_qty_value=10,
         default_qty_type = strategy.percent_of_equity, pyramiding=0)

// Initial Backtest Date Range
useStartDate = timestamp("01 Jan 2020 21:00:00")
useEndDate   = timestamp("01 Jan 2023 21:00:00")

// User Inputs
SIGNAL_CONFIG          = "BACKTEST: STORMER STRATEGY (123)"
longEntryInput         = input.bool(defval=true,         title="Long Entry",                     group=SIGNAL_CONFIG)
shortEntryInput        = input.bool(defval=true,         title="Short entry",                    group=SIGNAL_CONFIG)
thresholdForEntryInput = input.int(defval=3,             title="Threshold on clandes for entry", group=SIGNAL_CONFIG)
insideBarStrategyTitle = "Only third candle inside bar is valid"
insideBarStrategyTip   = "According to Stomer, it would be the best signal for the strategy"
insideBarStrategyInput = input.bool(defval=true,         title=insideBarStrategyTitle,           group=SIGNAL_CONFIG, tooltip=insideBarStrategyTip)
EMA_CONFIG             = "BACKTEST: EXPONENTIAL MOVING AVERAGES"
sourceInput            = input.source(defval=close,      title="Source",           inline="01",  group=EMA_CONFIG)
emaTimeframeInput      = input.timeframe("1W",           title="Timeframe",        inline="01",  group=EMA_CONFIG)
emaOffsetInput         = input.int(defval=8,             title="Offset",           inline="01",  group=EMA_CONFIG)
fastEMALengthInput     = input.int(defval=8,             title="Fast EMA Length",  inline="02",  group=EMA_CONFIG)
useFastEMAInput        = input.bool(defval=true,         title="Use Fast EMA",     inline="02",  group=EMA_CONFIG)
slowEMALengthInput     = input.int(defval=80,            title="Slow EMA Length",  inline="03",  group=EMA_CONFIG)
useSlowEMAInput        = input.bool(defval=true,         title="Use Slow EMA",     inline="03",  group=EMA_CONFIG)
PERIOD_CONFIG          = "BACKTEST: TIME PERIOD"
useDateFilterInput     = input.bool(defval=true,         title="Filter Date Range of Backtest",  group=PERIOD_CONFIG)
backtestStartDateInput = input(defval=useStartDate, title="Start Date",                     group=PERIOD_CONFIG)
backtestEndDateInput   = input(defval=useEndDate,   title="End Date",                       group=PERIOD_CONFIG)

// Colors
bbBackgroundColor  = color.rgb(33, 150, 243, 90)
candleColorDown    = color.rgb(239, 83, 80, 80)
candleColorUp      = color.rgb(38, 166, 154, 70)
insideBarColorDown = color.rgb(239, 83, 80, 40)
insideBarColorUp   = color.rgb(38, 166, 154, 20)
downTrendColor     = color.rgb(239, 83, 80, 80)
sidewaysTrendColor = color.rgb(252, 232, 131, 80)
upTrendColor       = color.rgb(38, 166, 154, 80)
buySignalColor     = color.lime
sellSignalColor    = color.orange

// Candles
isCandleUp()   => close > open
isCandleDown() => close <= open
barcolor(isCandleUp() ? candleColorUp : isCandleDown() ? candleColorDown : na)

// Exponential Moving Averages
fastEMA         = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput),    barmerge.gaps_on,  barmerge.lookahead_on)
currentFastEMA  = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput),    barmerge.gaps_off, barmerge.lookahead_on)
previousFastEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], fastEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)
slowEMA         = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput),    barmerge.gaps_on,  barmerge.lookahead_on)
currentSlowEMA  = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput),    barmerge.gaps_off, barmerge.lookahead_on)
previousSlowEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], slowEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)

// Trend Rules for Exponential Moving Averages
isSlowEMAUp()   => currentSlowEMA > previousSlowEMA
isSlowEMADown() => currentSlowEMA < previousSlowEMA
isFastEMAUp()   => currentFastEMA > previousFastEMA
isFastEMADown() => currentFastEMA < previousFastEMA

// Exponential Moving Average Colors
fastEMAColor = isFastEMAUp() ? upTrendColor : isFastEMADown() ? downTrendColor : sidewaysTrendColor
slowEMAColor = isSlowEMAUp() ? upTrendColor : isSlowEMADown() ? downTrendColor : sidewaysTrendColor

// Display Exponential Moving Averages
plot(useFastEMAInput ? fastEMA : na, offset=emaOffsetInput, color=fastEMAColor, title="Fast EMA", style=plot.style_line, linewidth=4)
plot(useSlowEMAInput ? slowEMA : na, offset=emaOffsetInput, color=slowEMAColor, title="Slow EMA", style=plot.style_line, linewidth=7)

// Price Trend
pricesAboveFastEMA() => low[2] > currentFastEMA and low[1] > currentFastEMA and low > currentFastEMA
pricesAboveSlowEMA() => low[2] > currentSlowEMA and low[1] > currentSlowEMA and low > currentSlowEMA
pricesBelowFastEMA() => high[2] < currentFastEMA and high[1] < currentFastEMA and high < currentFastEMA
pricesBelowSlowEMA() => high[2] < currentSlowEMA and high[1] < currentSlowEMA and high < currentSlowEMA

// Market in Bullish Trend
isBullishTrend() =>
    if useFastEMAInput and useSlowEMAInput
        pricesAboveFastEMA() and pricesAboveSlowEMA()
    else if useFastEMAInput
        pricesAboveFastEMA()
    else if useSlowEMAInput
        pricesAboveSlowEMA()
    else
        na

// Market in Bearish Trend
isBearishTrend() =>
    if useFastEMAInput and useSlowEMAInput
        pricesBelowFastEMA() and pricesBelowSlowEMA()
    else if useFastEMAInput
        pricesBelowFastEMA()
    else if useSlowEMAInput
        pricesBelowSlowEMA()
    else
        na

// Stormer Strategy (123)
isFirstCandleUp()   => high[2] > high[1] and low[2] > low[1]
isFirstCandleDown() => high[2] < high[1] and low[2] < low[1]
isThirdCandleUp()   => low > low[1]
isThirdCandleDown() => high < high[1]
isThirdCandleInsideBar() => high < high[1] and low > low[1]

// Buy Signal
isStormer123Buy() =>
    if insideBarStrategyInput
        longEntryInput and isFirstCandleUp() and isThirdCandleInsideBar() and isBullishTrend()
    else
        longEntryInput and isFirstCandleUp() and isThirdCandleUp() and isBullishTrend()

// Sell Signal
isStormer123Sell() =>
    if insideBarStrategyInput
        shortEntryInput and isFirstCandleDown() and isThirdCandleInsideBar() and isBearishTrend()
    else
        shortEntryInput and isFirstCandleDown() and isThirdCandleDown() and isBearishTrend()

// Backtest Time Period
inTradeWindow             = true
isInTradeWindow()         => inTradeWindow
isBacktestDateRangeOver() => not inTradeWindow and inTradeWindow[1]

// Backtest Price Parameters
highestPrice = ta.highest(high, 3)
lowestPrice  = ta.lowest(low,3)
priceRange   = highestPrice - lowestPrice

// Stormer Strategy (123): LONG
var myLongOrders = array.new_int(0)
longtEntryID     = "Long Entry:\n" + str.tostring(bar_index)
longExitID       = "Long Exit:\n" + str.tostring(bar_index)
stopLossInLong   = lowestPrice + 0.01
takeProfitInLong = priceRange + high

longEntryHasBeenMet = isInTradeWindow() and isBullishTrend() and isStormer123Buy()

// Scheduling LONG entry
if longEntryHasBeenMet
    array.push(myLongOrders, bar_index)
    strategy.order(longtEntryID, strategy.long, stop=high)
    strategy.exit(longExitID, longtEntryID, stop=stopLossInLong, limit=takeProfitInLong)

// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myLongOrders) == 0 ? na : array.size(myLongOrders) - 1)
    myLongOrder = array.get(myLongOrders, myOrderIndex)
    if bar_index - myLongOrder == thresholdForEntryInput
        longEntryID = "Long Entry:\n" + str.tostring(myLongOrder)
        strategy.cancel(longEntryID)

// Stormer Strategy (123): SHORT
var myShortOrders = array.new_int(0)
shortEntryID      = "Short Entry:\n" + str.tostring(bar_index)
shortExitID       = "Short Exit:\n" + str.tostring(bar_index)
stopLossInShort   = highestPrice + 0.01
takeProfitInShort = low - priceRange

shortEntryHasBeenMet = isInTradeWindow() and isBearishTrend() and isStormer123Sell()

// Scheduling SHORT entry
if shortEntryHasBeenMet
    array.push(myShortOrders, bar_index)
    strategy.order(shortEntryID, strategy.short, stop=low)
    strategy.exit(shortExitID, shortEntryID, stop=stopLossInShort, limit=takeProfitInShort)

// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myShortOrders) == 0 ? na : array.size(myShortOrders) - 1)
    myShortOrder = array.get(myShortOrders, myOrderIndex)
    if bar_index - myShortOrder == thresholdForEntryInput
        shortEntryID := "Short Entry:\n" + str.tostring(myShortOrder)
        strategy.cancel(shortEntryID)

// Close all positions at the end of the backtest period
if isBacktestDateRangeOver()
    strategy.cancel_all()
    strategy.close_all(comment="Date Range Exit")

// Display Signals
plotshape(series=longEntryHasBeenMet,  title="123 Buy",  style=shape.triangleup,   location=location.belowbar, color=buySignalColor,  text="123", textcolor=buySignalColor)
plotshape(series=shortEntryHasBeenMet, title="123 Sell", style=shape.triangledown, location=location.abovebar, color=sellSignalColor, text="123", textcolor=sellSignalColor)

더 많은