트렌드 추종 EMA 브레이크아웃 전략


생성 날짜: 2024-01-12 14:23:11 마지막으로 수정됨: 2024-01-12 14:23:11
복사: 0 클릭수: 620
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

트렌드 추종 EMA 브레이크아웃 전략

개요

이 전략은 지수 이동 평균 (EMA) 에 기반한 트렌드 추적형의 브레이크 전략이다. 달선, 주선, 일선 시간 프레임에 트렌드 방향을 판단하고 일선에 구체적인 입출력 작업을 수행한다.

전략 원칙

트렌드 판단

  1. 월선에서, 가격이 8일 EMA보다 높고, 8일 EMA는 21일 EMA보다 높으며, 다목적 경향으로 판단된다.
  2. 주위선에서, 가격은 8일 EMA, 8일 EMA는 21일 EMA보다 높으며, 다목적 경향으로 판단된다.
  3. 일선에서, 가격은 8일 EMA보다 높고, 8일 EMA는 21일 EMA보다 높으며, 다목적 경향으로 판단된다.

출입 신호

  1. 이 지표는 지난 8일 EMA에 도달한 지점으로 낮아지고 있다.
  2. 로워 하이와 로워 로우의 링 로우 형태를 구성하는 회음;
  3. 마감 가격이 전날의 최고 가격보다 높으면 트렌드 반전 신호가 됩니다.

출구 신호

정지 손실 기준을 설정하여 탈퇴에 도달하십시오.

우위 분석

  1. 세 시간 프레임의 추세를 판단하여 판단의 정확성을 높여라.
  2. 리모델링 하위점은 EMA의 구성지원에 영향을 미치며, 진출의 확실성을 증가시킵니다.
  3. 트렌드를 추적하고 수익 가능성이 높습니다.

위험 분석

  1. 3개의 시간 프레임의 일치하지 않는 판단은 잘못된 신호를 유발할 수 있습니다.
  2. “이런 전략은 너무 큰 폭으로 재조정되면 효과가 떨어집니다.
  3. 시장의 단절은 손실을 줄 수 있습니다.

최적화 방향

  1. MACD, RSI 등과 같은 지표들을 추가하는 것.
  2. EMA 변수 설정을 최적화합니다.
  3. 변동률 지표와 결합하여 스톱 스톱 손실을 조정합니다.

요약하다

이 전략은 전체적으로 트렌드 추적 전략으로서, 트렌드를 올바르게 판단할 때, 수익 잠재력이 매우 좋다. 트렌드 판단 오류와 회귀 과잉으로 잘못된 신호를 생성하는 것을 막기 위해 주의가 필요합니다. 또한, 스톱 스톱 손실 설정을 최적화하는 것은 전략의 우위를 더욱 높이는 데 중요합니다.

전략 소스 코드
/*backtest
start: 2023-01-11 00:00:00
end: 2024-01-11 00:00: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/
// © the_daily_trader

//@version=5
// ---------------------        Start of Code        ---------------------
strategy("Swing Trades Validator", overlay=true, margin_long=100, pyramiding = 0)

// Indicator Display Checks
TakeProfitPercent       = input.float(title="Profit Target %", defval=10, minval=1, step=0.05)
StopLossPercent         = input.float(title="Stop Loss %", defval=10, minval=1, step=0.05)
pullbackchoice          = input.bool(false, "Relaxed Entry Rules")

// EMAs
emaH            = ta.ema(close, 8)
emaHyest        = ta.ema(close[1], 8)
emaHyest1       = ta.ema(close[2], 8)
emaHyest2       = ta.ema(close[3], 8)
emaL            = ta.ema(close, 21)
emaLyest        = ta.ema(close[1], 21)
emaLyest1       = ta.ema(close[2], 21)
emaLyest2       = ta.ema(close[3], 21)
emaf            = ta.ema(close, 50)
emath           = ta.ema(close, 200)
emathhigh       = ta.ema(high, 200)
emathlow        = ta.ema(low, 200)
emaslowmonthly  = request.security(syminfo.tickerid, "M", emaL) // Monthly 21ema
emafastmonthly  = request.security(syminfo.tickerid, "M", emaH) // Monthly 8ema
emaslowweekly   = request.security(syminfo.tickerid, "W", emaL) // Weekly 21ema
emafastweekly   = request.security(syminfo.tickerid, "W", emaH) // Weekly 8ema
emaslowdaily    = request.security(syminfo.tickerid, "D", emaL) // Daily 21ema
emafastdaily    = request.security(syminfo.tickerid, "D", emaH) // Daily 8ema
emafdaily       = request.security(syminfo.tickerid, "D", emaf) // Daily 50ema
emathdaily      = request.security(syminfo.tickerid, "D", emath) // Daily ema
emathdailyhigh  = request.security(syminfo.tickerid, "D", emathhigh) // Daily ema High
emathdailylow   = request.security(syminfo.tickerid, "D", emathlow) // Daily ema Low
ema21yest       = request.security(syminfo.tickerid, "D", emaLyest) // Daily 21ema 1 day ago
ema21yest1      = request.security(syminfo.tickerid, "D", emaLyest1) // Daily 21ema 2 days ago
ema21yest2      = request.security(syminfo.tickerid, "D", emaLyest2) // Daily 21ema 3 days ago
ema8yest        = request.security(syminfo.tickerid, "D", emaHyest) // Daily 8ema 1 day ago
ema8yest1       = request.security(syminfo.tickerid, "D", emaHyest1) // Daily 8ema 2 days ago
ema8yest2       = request.security(syminfo.tickerid, "D", emaHyest2) // Daily 8ema 3 days ago


// Prices
monthopen       = request.security(syminfo.tickerid, 'M', open, barmerge.gaps_off, barmerge.lookahead_on)
monthclose      = request.security(syminfo.tickerid, 'M', close, barmerge.gaps_off, barmerge.lookahead_on)
weekopen        = request.security(syminfo.tickerid, 'W', open, barmerge.gaps_off, barmerge.lookahead_on)
weekclose       = request.security(syminfo.tickerid, 'W', close, barmerge.gaps_off, barmerge.lookahead_on)
dayopen         = request.security(syminfo.tickerid, 'D', open, barmerge.gaps_off, barmerge.lookahead_on)
dayclose        = request.security(syminfo.tickerid, 'D', close, barmerge.gaps_off, barmerge.lookahead_on)
threedayhigh    = request.security(syminfo.tickerid, 'D', high[3], barmerge.gaps_off, barmerge.lookahead_on)
twodayhigh      = request.security(syminfo.tickerid, 'D', high[2], barmerge.gaps_off, barmerge.lookahead_on)
yesthigh        = request.security(syminfo.tickerid, 'D', high[1], barmerge.gaps_off, barmerge.lookahead_on)
yestlow         = request.security(syminfo.tickerid, 'D', low[1], barmerge.gaps_off, barmerge.lookahead_on)

// Conditions 
monthlybullish          = emafastmonthly > emaslowmonthly
monthlybullishprice     = close > emafastmonthly
monthlybullishcandle    = monthclose > monthopen
weeklybullish           = emafastweekly > emaslowweekly
weeklybullishprice      = close > emafastweekly
weeklybullishcandle     = weekclose > weekopen
dailybullish1           = emafdaily > emathdaily
dailybullish2           = emafastdaily > emaslowdaily
dailybullishprice       = close > emafastdaily
dailybullishcandle      = dayclose > dayopen
ringlow                 = yestlow <= ema8yest
aggropullback           = twodayhigh < threedayhigh
pullback                = (pullbackchoice ? aggropullback : 0)
pullbackfailure         = dayclose > yesthigh and yesthigh < twodayhigh or pullback
emasetup                = ema8yest > ema21yest and ema8yest1 > ema21yest1 and ema8yest2 > ema21yest2

// Target Profit and Stop Loss Inputs
// Input parameters can be found at the beginning of the code
ProfitTarget        = (close * (TakeProfitPercent / 100)) / syminfo.mintick
StopLoss            = (close * (StopLossPercent / 100)) / syminfo.mintick

longCondition = monthlybullish and monthlybullishprice and weeklybullish and weeklybullishprice and dailybullish1 and dailybullish2 and dailybullishprice and monthlybullishcandle and weeklybullishcandle and dailybullishcandle and ringlow and pullbackfailure and emasetup

if (longCondition)
    strategy.entry("Long", strategy.long)
    strategy.exit ("Exit", "Long", profit = ProfitTarget, loss = StopLoss)
    // strategy.close("Long", qty_percent = 100)


// -----------xxxxxxxxxxx-------------    End of Code     -----------xxxxxxxxxxx---------------