더블 EMA 골든 크로스 브레이크아웃 전략


생성 날짜: 2023-12-20 16:34:58 마지막으로 수정됨: 2023-12-20 16:34:58
복사: 1 클릭수: 719
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

더블 EMA 골든 크로스 브레이크아웃 전략

개요

이 전략은 5분과 34분 지수 이동 평균 ((EMA) 에 기초한 골드 크로스 및 데이트 크로스 작업을 하는 트렌드 추적 전략이다. 빠른 선이 아래에서 느린 선을 통과할 때, 긴 포지션을 열고, 빠른 선이 위에서 아래에서 느린 선을 통과할 때, 빈 포지션을 열고, 위험을 제어하기 위해 스톱을 설정한다.

전략 원칙

  1. 빠른 EMA5와 느린 EMA34은 거래 신호를 구성한다. EMA5는 가격의 최근의 변화에 반응하고, EMA34는 가격의 중간 변화에 반응한다.
  2. 빠른 선에서 느린 선을 통과할 때, 금으로 교차, 단기상황이 중기상황보다 낫다는 것을 나타내며, 더 많은 상자를 보유한다.
  3. 빠른 선 아래로 느린 선을 통과할 때, 죽음의 교차로, 단기상황이 중기상황보다 나쁘다는 것을 나타내며, 항공권을 보유하고 있다.
  4. 수익을 고정하고 위험을 통제하기 위해 스톱톱을 설정하십시오.

우위 분석

  1. 이중 EMA 필터로 가짜 돌파구를 사용해서 을 피할 수 있다.
  2. 중장기 트렌드를 추적하고 수익을 창출할 수 있습니다.
  3. 스톱 스톱 손실을 설정하여 위험을 효과적으로 제어하십시오.

위험 분석

  1. 이중 EMA는 지연성이 있어 단기 거래 기회를 놓칠 수 있다.
  2. 스톱포인트 설정이 너무 커서 손실이 커질 위험이 있습니다.
  3. 이 경우, 이 지점을 너무 작게 설정하여 수익을 극대화 할 수 없습니다.

최적화 방향

  1. EMA 변수를 최적화하여 최적의 변수 조합을 찾습니다.
  2. 스티드포드 손실을 최적화하여 더 많은 을 잠금합니다.
  3. MACD, KDJ 등과 같은 다른 지표 필터를 추가하여 신호의 정확성을 향상시킵니다.

요약하다

이 전략은 두 개의 EMA 이동 평균의 황금 교차와 죽음의 교차를 통해 거래 신호를 생성하고, 스톱 스톱을 설정하여 위험을 제어하는 간단한 효과적인 중기 트렌드 추적 전략입니다. 스톱 스톱 스톱의 매개 변수를 최적화하고, 다른 지표의 필터링 신호를 도입하면 전략의 안정적인 수익성을 더욱 강화 할 수 있습니다.

전략 소스 코드
/*backtest
start: 2023-11-01 00:00:00
end: 2023-11-30 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title='[STRATEGY][RS]MicuRobert EMA cross V2', shorttitle='S', overlay=true, pyramiding=0, initial_capital=100000)
USE_TRADESESSION = input(title='Use Trading Session?', type=bool, defval=true)
USE_TRAILINGSTOP = input(title='Use Trailing Stop?', type=bool, defval=true)
trade_session = input(title='Trade Session:',defval='0400-1500', confirm=false)
istradingsession = not USE_TRADESESSION ? false : not na(time('1', trade_session))
bgcolor(istradingsession?gray:na)
trade_size = input(title='Trade Size:', type=float, defval=1)
tp = input(title='Take profit in pips:', type=float, defval=55.0) * (syminfo.mintick*10)
sl = input(title='Stop loss in pips:', type=float, defval=22.0) * (syminfo.mintick*10)
ma_length00 = input(title='EMA length:',  defval=5)
ma_length01 = input(title='DEMA length:',  defval=34)
price = input(title='Price source:',  defval=open)

//  ||--- NO LAG EMA, Credit LazyBear:  ---||
f_LB_zlema(_src, _length)=>
    _ema1=ema(_src, _length)
    _ema2=ema(_ema1, _length)
    _d=_ema1-_ema2
    _zlema=_ema1+_d
//  ||-------------------------------------||

ma00 = f_LB_zlema(price, ma_length00)
ma01 = f_LB_zlema(price, ma_length01)
plot(title='M0', series=ma00, color=black)
plot(title='M1', series=ma01, color=black)

isnewbuy = change(strategy.position_size)>0 and change(strategy.opentrades)>0
isnewsel = change(strategy.position_size)<0 and change(strategy.opentrades)>0

buy_entry_price = isnewbuy ? price : buy_entry_price[1]
sel_entry_price = isnewsel ? price : sel_entry_price[1]
plot(title='BE', series=buy_entry_price, style=circles, color=strategy.position_size <= 0 ? na : aqua)
plot(title='SE', series=sel_entry_price, style=circles, color=strategy.position_size >= 0 ? na : aqua)
buy_appex = na(buy_appex[1]) ? price : isnewbuy ? high : high >= buy_appex[1] ? high : buy_appex[1]
sel_appex = na(sel_appex[1]) ? price : isnewsel ? low : low <= sel_appex[1] ? low : sel_appex[1]
plot(title='BA', series=buy_appex, style=circles, color=strategy.position_size <= 0 ? na : teal)
plot(title='SA', series=sel_appex, style=circles, color=strategy.position_size >= 0 ? na : teal)
buy_ts = buy_appex - sl
sel_ts = sel_appex + sl
plot(title='Bts', series=buy_ts, style=circles, color=strategy.position_size <= 0 ? na : red)
plot(title='Sts', series=sel_ts, style=circles, color=strategy.position_size >= 0 ? na : red)

buy_cond1 = crossover(ma00, ma01) and (USE_TRADESESSION ? istradingsession : true)
buy_cond0 = crossover(price, ma00) and ma00 > ma01 and (USE_TRADESESSION ? istradingsession : true)
buy_entry = buy_cond1 or buy_cond0
buy_close = (not USE_TRAILINGSTOP ? low <= buy_entry_price - sl: low <= buy_ts) or high>=buy_entry_price+tp//high>=last_traded_price + tp or low<=last_traded_price - sl //high >= hh or 
sel_cond1 = crossunder(ma00, ma01) and (USE_TRADESESSION ? istradingsession : true)
sel_cond0 = crossunder(price, ma00) and ma00 < ma01 and (USE_TRADESESSION ? istradingsession : true)
sel_entry = sel_cond1 or sel_cond0
sel_close = (not USE_TRAILINGSTOP ? high >= sel_entry_price + sl : high >= sel_ts) or low<=sel_entry_price-tp//low<=last_traded_price - tp or high>=last_traded_price + sl //low <= ll or 

strategy.entry('buy', long=strategy.long, qty=trade_size, comment='buy', when=buy_entry)
strategy.close('buy', when=buy_close)
strategy.entry('sell', long=strategy.short, qty=trade_size, comment='sell', when=sel_entry)
strategy.close('sell', when=sel_close)