
이 전략은 다중 지수 이동 평균 ((EMA) 와 실제 파도 지표 ((ATR) 를 기반으로 한 트렌드 추적 거래 시스템이다. 전략은 여러 평행선의 배열 형태를 판단하여 트렌드 방향을 확인하고, 상승 추세에서 역전 구매 기회를 찾고, ATR 동력을 사용하여 중지 손실 및 수익 목표를 설정한다. 이 방법은 트렌드 추적의 안정성을 보장하고, ATR을 통해 시장의 변동에 대한 동적 적응을 구현한다.
전략의 핵심 논리에는 다음과 같은 핵심 요소가 포함됩니다.
이것은 구조적이고 논리적으로 엄격한 트렌드 추적 전략이다. 다중 평균선 확인 트렌드, 회전 입점 및 ATR 동적 위험 관리의 조합으로 전략의 안정성을 보장하고, 좋은 적응력을 갖추고 있다. 일부 고유한 위험이 있지만, 제안된 최적화 방향은 전략의 안정성과 수익성을 더욱 향상시킬 수 있다. 이 전략은 중장기 트렌드를 추적하는 데 특히 적합하며, 트렌드 시장에서 안정적인 수익을 기대하는 거래자에게는 좋은 선택이다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover and ATR Target Strategy", overlay=true)
// Input parameters
emaShortLength = 20
emaMidLength1 = 50
emaMidLength2 = 100
emaLongLength = 200
atrLength = 14
// Calculate EMAs
ema20 = ta.ema(close, emaShortLength)
ema50 = ta.ema(close, emaMidLength1)
ema100 = ta.ema(close, emaMidLength2)
ema200 = ta.ema(close, emaLongLength)
ema21 = ta.ema(close, 21)
// Calculate ATR
atr = ta.atr(atrLength)
// Conditions for the strategy
emaCondition = ema20 > ema50 and ema50 > ema100 and ema100 > ema200
pullbackCondition = close <= ema21 and close >= ema50 //and close >= ema21 * 0.99 // Near 21 EMA (within 1%)
// Initialize variables for stop loss and take profitss
var float stopLossLevel = na
var float takeProfitLevel = na
// Check conditions on each bar close
if (bar_index > 0) // Ensures there is data to check
if emaCondition and pullbackCondition and strategy.position_size == 0 // Only buy if no open position
stopLossLevel := close - (1.5 * atr) // Set stop loss based on ATR at buy price
takeProfitLevel := close + (3.5 * atr) // Set take profit based on ATR at buy price
strategy.entry("Buy", strategy.long)
// Set stop loss and take profit for the active trade
if strategy.position_size > 0
strategy.exit("Take Profit", from_entry="Buy", limit=takeProfitLevel, stop=stopLossLevel)
// Plot EMAs for visualizationn
plot(ema20, color=color.blue, title="20 EMA")
plot(ema50, color=color.red, title="50 EMA")
plot(ema100, color=color.green, title="100 EMA")
plot(ema200, color=color.orange, title="200 EMA")
plot(ema21, color=color.purple, title="21 EMA")