
이 전략은 5일 지수 이동 평균 ((EMA5)) 과 13일 지수 이동 평균 ((EMA13) 의 교차를 사용하여 거래 신호를 생성한다. EMA5 상위에서 EMA13를 통과하면 다중 신호가 발생하며, EMA5 아래에서 EMA13를 통과하면 공백 신호가 발생한다. 이 전략은 단기 경향의 변화를 포착하고, 두 개의 이동 평균의 교차를 사용하여 입점과 출구를 결정한다.
이 전략의 핵심은 두 개의 다른 기간의 지수 이동 평균 (EMA) 의 교차를 사용하여 거래 신호를 생성하는 것이다. EMA는 일반적으로 사용되는 기술 지표이며, 최근의 가격 데이터에 더 높은 무게를 부여하고, 따라서 간단한 이동 평균 (SMA) 에 비해 가격의 변화를 더 잘 반영한다. 단기 EMA (EMA5) 가 상위에서 장기 EMA (EMA13) 를 통과할 때, 가격 상승 동력이 강화될 수 있음을 나타내고, 다중 신호를 생성한다. 반대로, 단기 EMA가 아래로 EMA를 통과할 때, 가격 하락 동력이 강화될 수 있음을 나타내고, 공백 신호를 생성한다.
EMA5와 EMA13 교차 전략은 두 개의 다른 주기적 EMA의 교차를 통해 가격 추세의 변화를 포착하는 간단한 트렌드 추적 전략이다. 이 전략의 장점은 단순하고 적응력이 강하며 시기적절성이 높지만, 동시에 가짜 신호, 지연성 및 중단 부족 등의 위험이 있습니다. 전략의 성능을 더 이상 최적화하기 위해 추세 필터를 추가하고, 중지, 최적화 파라미터를 설정하고, 다른 기술 지표 방법과 결합하는 것을 고려 할 수 있습니다. 실제 응용에서는 특정 시장 환경과 거래 유형에 따라 조정 및 최적화가 필요합니다.
/*backtest
start: 2023-05-11 00:00:00
end: 2024-05-16 00:00:00
period: 2d
basePeriod: 1d
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/
// © Milankacha
//@version=5
strategy('5-13 EMA by Naimesh ver04', overlay=true)
qty = input(1, 'Buy quantity')
testStartYear = input(2021, 'Backtest Start Year')
testStartMonth = input(1, 'Backtest Start Month')
testStartDay = input(1, 'Backtest Start Day')
testStartHour = input(0, 'Backtest Start Hour')
testStartMin = input(0, 'Backtest Start Minute')
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, testStartHour, testStartMin)
testStopYear = input(2099, 'Backtest Stop Year')
testStopMonth = input(1, 'Backtest Stop Month')
testStopDay = input(30, 'Backtest Stop Day')
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)
testPeriodBackground = input(title='Color Background?', defval=true)
testPeriodBackgroundColor = testPeriodBackground and time >= testPeriodStart and time <= testPeriodStop ? #00FF00 : na
testPeriod() => true
ema1 = input(5, title='Select EMA 1')
ema2 = input(13, title='Select EMA 2')
//ema3 = input(50, title='Select EMA 3')
//SL = input(70, title='Stoploss')
//TR = input(250, title='Target')
expo = ta.ema(close, ema1)
ma = ta.ema(close, ema2)
//EMA_50 = ta.ema(close, ema3)
//avg_1 = avg (expo, ma)
//s2 = ta.cross(expo, ma) ? avg_1 : na
//plot(s2, style=plot.style_line, linewidth=3, color=color.red, transp=0)
p1 = plot(expo, color=color.rgb(231, 15, 15), linewidth=2)
p2 = plot(ma, color=#0db63a, linewidth=2)
fill(p1, p2, color=color.new(color.white, 80))
longCondition = ta.crossover(expo, ma)
shortCondition = ta.crossunder(expo, ma)
if testPeriod()
//strategy.entry('Long', strategy.long, when=longCondition)
strategy.entry('Short', strategy.short, when=expo<ma)
//strategy.close("Long", expo<ma, comment= 'SL hit')
strategy.close("Short", expo>ma, comment= 'SL hit')
//plotshape(longCondition and close>EMA_50, title='Buy Signal', text='B', textcolor=color.new(#FFFFFF, 0), style=shape.labelup, size=size.normal, location=location.belowbar, color=color.new(#1B8112, 0))
//plotshape(shortCondition and close<EMA_50, title='Sell Signal', text='S', textcolor=color.new(#FFFFFF, 0), style=shape.labeldown, size=size.normal, location=location.abovebar, color=color.new(#FF5733, 0))