
이 전략은 4배 지수 이동 평균 ((EMA) 에 기반한 트렌드 추적 시스템으로 9, 21, 50, 200 주기 EMA의 교차와 배열을 통해 시장의 트렌드를 식별하고, 백분율 스톱로즈와 결합하여 위험을 제어한다. 전략은 4개의 평행선의 배열 순서를 판단하여 시장의 트렌드 방향을 결정한다. 단기 평행선이 장기 평행선 위에 있을 때 더 많이 입주하고, 반대로 공백을 하고, 동시에 고정 백분율 스톱로즈를 설정하여 위험을 제어한다.
이 전략은 4개의 다른 주기의 지수 이동 평균을 사용해서 (9,21,50,200) 이평선 사이의 관계를 관찰하여 시장의 흐름을 판단한다. 9일 EMA가 21일 EMA 위에 있을 때, 21일 EMA가 50일 EMA 위에 있을 때, 50일 EMA가 200일 EMA 위에 있을 때, 시스템은 시장이 강렬한 상승 추세에 있다고 생각하고, 더 많이 발행한다.
이것은 구조가 온전한 트렌드 추적 거래 시스템으로, 다중 평균의 조합 사용으로 비교적 신뢰할 수 있는 트렌드 식별 메커니즘을 제공하며, 일정한 퍼센티지 스톱로스를 사용하여 위험을 통제한다. 시스템이 다소 뒤처져 있지만, 합리적인 매개 변수 최적화와 추가 지표의 보충을 통해 전략의 안정성과 수익성을 더욱 향상시킬 수 있다. 이 전략은 특히 변동성이 큰 시장과 중장기 트렌드 추적 거래에 적합하다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-23 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("4 EMA Strategy with Stop Loss", overlay=true)
// Define the EMA lengths
ema1_length = input(9, title="EMA 1 Length")
ema2_length = input(21, title="EMA 2 Length")
ema3_length = input(50, title="EMA 3 Length")
ema4_length = input(200, title="EMA 4 Length")
// Calculate the EMAs
ema1 = ta.ema(close, ema1_length)
ema2 = ta.ema(close, ema2_length)
ema3 = ta.ema(close, ema3_length)
ema4 = ta.ema(close, ema4_length)
// Plot EMAs on the chart
plot(ema1, color=color.blue, title="EMA 9")
plot(ema2, color=color.orange, title="EMA 21")
plot(ema3, color=color.green, title="EMA 50")
plot(ema4, color=color.red, title="EMA 200")
// Define conditions for Buy and Sell signals
buy_condition = (ema1 > ema2 and ema2 > ema3 and ema3 > ema4)
sell_condition = (ema1 < ema2 and ema2 < ema3 and ema3 < ema4)
// Input stop loss percentage
stop_loss_perc = input(2.0, title="Stop Loss %")
// Execute buy signal
if (buy_condition)
strategy.entry("Buy", strategy.long)
// Set stop loss at a percentage below the entry price
strategy.exit("Sell", "Buy", stop=strategy.position_avg_price * (1 - stop_loss_perc / 100))
// Execute sell signal
if (sell_condition)
strategy.entry("Sell", strategy.short)
// Set stop loss at a percentage above the entry price
strategy.exit("Cover", "Sell", stop=strategy.position_avg_price * (1 + stop_loss_perc / 100))