
이 전략은 주로 20·50 및 200 주기 지수 이동 평균 ((EMA) 의 교차 관계와 가격과 평균의 관계를 기반으로 진입 시기를 판단하며, 백분율 기반의 중지 손실을 설정하여 위험을 제어합니다. 이 전략은 특히 1 시간, 일간 및 주간 차트와 같은 더 큰 시간 기간에 적합하며, 중기 및 장기적인 추세를 효과적으로 포착합니다.
이 전략의 핵심 논리는 다중평평선 시스템과 가격행동 분석에 기초한다:
이것은 합리적이고 논리적으로 명확하게 설계된 트렌드 추적 전략이다. 다중 기술 지표의 조합 사용으로 전략의 신뢰성을 보장하고 명확한 위험 제어 프로그램을 제공합니다. 전략은 특히 대주기 차트에서 작동하기에 적합하며 중기 및 중기 경향을 파악하는 데 독특한 이점이 있습니다. 제안된 최적화 방향에 의해 전략은 추가적으로 향상된다. 상인은 실제 사용 전에 피드백 시스템에서 충분히 테스트하고 특정 거래 품종의 특성에 따라 파라미터를 적절히 조정하는 것이 좋습니다.
/*backtest
start: 2024-10-28 00:00:00
end: 2024-11-27 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Cross Strategy with Targets and Fill", overlay=true)
// Define EMAs
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
// Plot EMAs (hidden)
plot(ema20, color=color.blue, title="EMA 20", display=display.none)
plot(ema50, color=color.red, title="EMA 50", display=display.none)
plot(ema200, color=color.green, title="EMA 200", display=display.none)
// Define the conditions
priceCrossAboveEMA20 = ta.crossover(close, ema20)
priceCloseAboveEMA20 = close > ema20
ema20AboveEMA50 = ema20 > ema50
ema50AboveEMA200 = ema50 > ema200
// Buy condition
buyCondition = priceCrossAboveEMA20 and priceCloseAboveEMA20 and ema20AboveEMA50 and ema50AboveEMA200
// Plot buy signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
// Declare and initialize variables for take profit and stop loss levels
var float longTakeProfit = na
var float longStopLoss = na
var float buyPrice = na
// Update levels and variables on buy condition
if (buyCondition)
// Enter a new buy position
strategy.entry("Buy", strategy.long)
// Set new take profit and stop loss levels
longTakeProfit := strategy.position_avg_price * 1.10 // Target is 10% above the buy price
longStopLoss := strategy.position_avg_price * 0.95 // Stop loss is 5% below the buy price
buyPrice := strategy.position_avg_price
// Plot levels for the new trade
plotTakeProfit = plot(longTakeProfit, color=color.green, title="Take Profit", linewidth=1, offset=-1)
plotStopLoss = plot(longStopLoss, color=color.red, title="Stop Loss", linewidth=1, offset=-1)
plotBuyPrice = plot(buyPrice, color=color.blue, title="Buy Price", linewidth=1, offset=-1)
// Fill areas between buy price and take profit/stop loss levels
fill(plotBuyPrice, plotTakeProfit, color=color.new(color.green, 90), title="Fill to Take Profit") // Light green fill to target
fill(plotBuyPrice, plotStopLoss, color=color.new(color.red, 90), title="Fill to Stop Loss") // Light red fill to stop loss
// Exit conditions
strategy.exit("Take Profit/Stop Loss", from_entry="Buy", limit=longTakeProfit, stop=longStopLoss)