트렌드 트레이딩과 듀얼 EMA 크로스오버 시스템

저자:차오장, 날짜: 2023-10-26 17:15:46
태그:

img

전반적인 설명

이중 EMA 크로스오버 시스템은 두 개의 기하급수적인 이동 평균 (EMA) 을 기반으로 한 트렌드 다음 거래 시스템이다. 현재 트렌드 방향을 결정하고 그에 따라 거래 신호를 생성하기 위해 서로 다른 기간을 가진 두 개의 EMA를 사용합니다. 간단한 논리와 쉬운 구현으로이 시스템은 시장 트렌드를 효과적으로 캡처 할 수 있으며 중장기 거래자에게 적합합니다.

어떻게 작동 합니까?

이 시스템의 핵심은 두 개의 EMA에 의존합니다. 하나는 더 빠른 EMA, 다른 하나는 더 느린 EMA입니다. 빠른 EMA가 느린 EMA보다 높을 때, 상승률로 간주됩니다. 빠른 EMA가 느린 EMA보다 낮을 때, 하락률로 간주됩니다.

두 EMA와의 가격 관계에 따라 바는 다른 거래 구역으로 분류 될 수 있습니다.

  • 빠른 EMA가 느린 EMA보다 높고 가격이 빠른 EMA (G1) 보다 높을 때, 이것은 강한 구매 구역입니다. 여기서 긴 지위를 취할 수 있습니다.

  • 빠른 EMA가 느린 EMA보다 낮고 가격이 빠른 EMA (R1) 보다 낮을 때, 이것은 강한 판매 구역입니다. 여기서 짧은 지위를 취할 수 있습니다.

  • 두 EMA가 교차할 때, 경고 (노랑) 및 전환 (황황색) 구역은 두 EMA와의 가격 관계에 따라 결정됩니다.이 구역은 잠재적 인 트렌드 전환을 나타냅니다. 추가 지표를 사용하여 신중하게 거래해야합니다.

거래 신호는 가격이 서로 다른 영역을 넘어서 움직일 때 생성된다. 강한 영역 G1과 R1에서는 신호를 직접 얻을 수 있다. 경고 및 전환 영역에서는 추가 지표 확인이 필요하다.

또한 StochRSI는 잠재적 진입점과 출구점을 식별하는 데 도움이 되도록 구현됩니다. StochRSI에서 과반 판매 및 과반 구매 판독은 추가 구매 및 판매 신호를 제공할 수 있습니다.

장점

  • 단순하고 깔끔한 논리, 이해하기 쉽고 실행하기 쉬운

  • 중장기 동향을 효과적으로 파악합니다

  • 강력한 구역과 경고/전환 구역을 구별하여 신뢰할 수 있는 무역 신호를 생성합니다.

  • StochRSI를 포함하면 출입 및 출출 시기가 더 향상됩니다.

위험성

  • 순수한 트렌드 추종 시스템으로서, 트렌드가 아닌 시장에서 성과가 떨어질 수 있습니다.

  • 부적절한 EMA 기간 설정은 잘못된 신호를 일으킬 수 있습니다.

  • 경고 구역과 전환 구역은 거래 위험이 높으므로 신중하게 다루어야 합니다.

  • 스톱 로스의 부재로 인해 손실이 증가할 수 있습니다.

위험은 다음과 같이 감소 할 수 있습니다.

  1. 트렌드가 강한 기구를 선택하고 트렌드가 약한 경우 거래를 중단합니다.

  2. 잘못된 신호를 최소화하기 위해 EMA 기간을 최적화

  3. 경고/이전 구역에서 확인을 위한 추가 지표 도입

  4. 거래당 손실을 제어하기 위한 스톱 로스 구현

더 나은 기회

이 시스템은 다음 영역에서 더 개선될 수 있습니다.

  1. 신호 확인을 위해 MACD, KDJ와 같은 더 많은 지표를 포함

  2. 무역 성공률을 향상시키기 위해 거래 구역의 부피 확장이 같은 필터를 추가하십시오.

  3. 최적화된 매개 변수를 위해 시장 조건에 따라 EMA 기간을 동적으로 조정합니다.

  4. 특정 손실 비율로 거래를 종료하기 위해 스톱 로스 전략을 실행하십시오.

  5. 포지션 크기와 자금 관리 최적화

  6. 가장 좋은 구성을 찾기 위해 다른 도구에 대한 테스트 및 미세 조정 매개 변수

더 많은 신호 확인, 동적 매개 변수 최적화, 스톱 로스 및 적절한 돈 관리를 도입함으로써 시스템의 안정성이 향상되고 더 나은 결과를 위해 위험을 줄일 수 있습니다.

결론

이중 EMA 크로스오버 시스템은 두 개의 EMA를 비교하는 데 기반한 트렌드 추적 시스템이다. 트렌드 방향을 결정하고 거래 신호를 생성하기 위해 EMA와 가격의 관계를 기반으로 다른 거래 구역을 식별한다. 명확한 논리와 쉬운 구현을 가진 시스템으로서 트렌드를 효과적으로 캡처할 수 있다. 위험이 존재하지만 보조 지표, 동적 최적화, 스톱 로스, 그리고 돈 관리를 통해 줄일 수 있다. 전반적으로 이중 EMA 크로스오버 시스템은 중장기 트레이더에 적합한 탄탄한 트렌드 추적 시스템이다.


/*backtest
start: 2023-01-01 00:00:00
end: 2023-10-25 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/
// © Vvaz_
//base-on CDC ActionZone By Piriya   a simple 2EMA and is most suitable for use with medium volatility market
//@version=4
strategy(title="Vin's Playzone" ,shorttitle="VPz", overlay=true, margin_long=4, margin_short=2)

//variable
srcf = input(title="Source",type=input.source,defval=close)
tffix = input(title="Fixed Timeframe",type=input.bool,defval=true)
tfn = input(title="Timeframe in",type=input.resolution,defval="D")
ema1 = input(title="Fast EMA",type=input.integer,defval=12)
ema2 = input(title="Slow EMA",type=input.integer,defval=26)
ema3 = input(title="EMA 100",type=input.bool,defval=true)
smooter =input(title="Smoothing period (1 = no smoothing)",type=input.integer,defval=2)
fillbar =input(title="Fill Bar Color",type=input.bool,defval=true)
emasw = input(title="Show EMA",type=input.bool,defval=true)
bssw = input(title="Show Buy-Sell signal",type=input.bool,defval=true)
plotmm = input(title="Show Buy-Sell Momentum",type=input.bool,defval=true)
plotmmsm = input(title="RSI Smoothing",type=input.integer,defval=0,minval=0,maxval=2)

//math
xcross =ema(srcf,smooter)
efast = tffix ?  ema(security(syminfo.tickerid,tfn,ema(srcf,ema1), gaps = barmerge.gaps_off,lookahead = barmerge.lookahead_on),smooter) :ema(xcross,ema1)
eslow = tffix ?  ema(security(syminfo.tickerid,tfn,ema(srcf,ema2), gaps = barmerge.gaps_off,lookahead = barmerge.lookahead_on),smooter) :ema(xcross,ema2)
ema3x = ema(xcross,100)


//Zone
Bull = efast > eslow
Bear = efast < eslow

G1 = Bull and xcross > efast //buy
G2 = Bear and xcross > efast and xcross > eslow //pre-buy1
G3 = Bear and xcross > efast and xcross < eslow //pre-buy2

R1 = Bear and xcross < efast //sell
R2 = Bull and xcross < efast and xcross < eslow //pre-sell1
R3 = Bull and xcross < efast and xcross > eslow //pre-sell2

//color
bcl =   G1 ? color.green :  G2 ? color.yellow : G3 ? color.orange :R1 ? color.red :R2 ? color.orange : R3 ? color.yellow : color.black
barcolor(color=fillbar ? bcl : na )

//plots
line1 = plot(ema3 ? ema3x : na ,"EMA100",color=color.white)
line2 = plot(emasw ? efast : na ,"Fast EMA",color=color.green)
line3 = plot(emasw ? eslow : na ,"Slow EMA",color=color.red)
fillcl = Bull ? color.green : Bear ? color.red : color.black
fill(line2,line3,fillcl)

//actions
buywhen = G1 and G1[1]==0
sellwhen = R1 and R1[1]==0

bullish = barssince(buywhen) < barssince(sellwhen)
bearish = barssince(sellwhen) < barssince(buywhen)

buy = bearish[1] and buywhen
sell = bullish[1] and sellwhen

bullbearcl = bullish ? color.green : bearish ? color.red : color.black

//plot trend
plotshape(bssw ? buy : na ,style=shape.arrowup,title="BUY",location=location.belowbar,color=color.green)
plotshape( bssw ? sell : na ,style=shape.arrowdown ,title="Sell",location=location.abovebar,color=color.red)

// Momentum Signal using StochRSI

smoothK = input(5,"StochRSI smooth K",type=input.integer,minval=1)
smoothD = input(4,"StochRSI smooth D",type=input.integer,minval=1)
RSIlen = input(14,"RSI length",type=input.integer,minval=1)
STOlen = input(14,"Stochastic length",type=input.integer,minval=1)
SRsrc = input(close,"Source for StochasticRSI",type=input.source)
OSlel = input(20,"Oversold Threshold",type=input.float,minval=0.00)
OBlel = input(80,"Oversold Threshold",type=input.float,minval=0.00)
rsil = rsi(SRsrc,RSIlen)
K = sma(stoch(rsil,rsil,rsil,STOlen),smoothK)
D = sma(K,smoothD)

buymore = iff( bullish ,iff(D < OSlel and crossover(K,D),	2,	 iff(D > OSlel and crossover(K,D),	 1,0)),0)
sellmore = iff( bearish,iff(D > OBlel and crossunder(K,D),	2,	 iff(D < OBlel and crossunder(K,D),	 1,0)),0)
//plot momentum
plotshape(plotmm ? buymore > plotmmsm ? buymore : na : na ,"Buy More!" ,style=shape.triangleup,location=location.belowbar,color=color.green)
plotshape(plotmm ? sellmore > plotmmsm ? sellmore : na : na ,"Sell More!" ,style=shape.triangledown,location=location.abovebar,color=color.red)


// === INPUT BACKTEST RANGE ===
FromYear  = input(defval = 2009, title = "From Year", minval = 2009)
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
ToYear    = input(defval = 9999, title = "To Year", minval = 2009)
ToMonth   = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
ToDay     = input(defval = 31, title = "To Day", minval = 1, maxval = 31)

// === FUNCTION EXAMPLE ===
start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false // create function "within window of time"

//stratgy excuter
strategy.entry("Long",true,when=window() and buy or buymore)
strategy.close("Long",when=window() and sell or sellmore,comment="TP Long")
strategy.entry("Short",false,when=window() and sell or sellmore)
strategy.close("Short",when=window() and buy or buymore,comment="TP Short")




        

더 많은