
이 전략은 다중 지수 이동 평균 (EMA) 을 기반으로 한 트렌드 추적 거래 시스템입니다. 가격 통과와 트렌드 방향 판단과 결합하여 세 개의 다른 주기 (10, 30, 50) 의 EMA 라인을 사용하여 전체적인 구매 및 판매 신호 시스템을 구축합니다. 전략 설계는 트렌드의 형성, 확인 및 전환을 충분히 고려하여 시장의 주요 트렌드 기회를 효과적으로 포착 할 수 있습니다.
전략은 거래 신호를 결정하기 위해 계층적 판단 메커니즘을 사용합니다.
이것은 합리적이고, 논리적으로 명확한 트렌드 추적 전략이다. 다중 평균의 조합 사용으로 전략의 안정성을 보장하고 명확한 거래 신호를 제공합니다. 약간의 지연 위험이 있지만, 합리적인 최적화 및 위험 제어 조치를 통해 전략 전체는 더 나은 실용적 가치를 보여줍니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © banyat6913
//@version=5
strategy("EMA Trend Strategy", overlay=true)
// Input Parameters
ema_short_length = input.int(10, title="EMA Short Length", minval=1)
ema_mid_length = input.int(30, title="EMA Mid Length", minval=1)
ema_long_length = input.int(50, title="EMA Long Length", minval=1)
// Calculate EMA
ema_short = ta.ema(close, ema_short_length)
ema_mid = ta.ema(close, ema_mid_length)
ema_long = ta.ema(close, ema_long_length)
// **TREND UP**
// 1. EMA 10 > EMA 30 > EMA 50
uptrend_condition = ema_short > ema_mid and ema_mid > ema_long
// 2. Bullish Candle Crossing Up EMA 30
bullish_candle = close > open
cross_up_ema_mid = ta.crossover(close, ema_mid)
// 3. If EMA 30 crosses down EMA 50 -> Close Buy Order
ema_30_cross_down_50 = ta.crossunder(ema_mid, ema_long)
// Buy Signal
buy_signal = uptrend_condition and cross_up_ema_mid
// Sell Signal for closing Buy Order
close_buy_signal = ema_30_cross_down_50
// **TREND DOWN**
// 1. EMA 50 > EMA 30 > EMA 10
downtrend_condition = ema_long > ema_mid and ema_mid > ema_short
// 2. Bearish Candle Crossing Down EMA 30
bearish_candle = close < open
cross_down_ema_mid = ta.crossunder(close, ema_mid)
// 3. If EMA 30 crosses up EMA 50 -> Close Sell Order
ema_30_cross_up_50 = ta.crossover(ema_mid, ema_long)
// Sell Signal
sell_signal = downtrend_condition and cross_down_ema_mid
// Buy Signal for closing Sell Order
close_sell_signal = ema_30_cross_up_50
// Backtesting Logic
if (buy_signal)
strategy.entry("Buy", strategy.long)
if (close_buy_signal)
strategy.close("Buy")
if (sell_signal)
strategy.entry("Sell", strategy.short)
if (close_sell_signal)
strategy.close("Sell")
// Plot EMA Lines
plot(ema_short, color=color.blue, title="EMA 10")
plot(ema_mid, color=color.orange, title="EMA 30")
plot(ema_long, color=color.green, title="EMA 50")
// Plot Buy and Sell Signals on Chart
plotshape(buy_signal, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), text="BUY", title="Buy Signal")
plotshape(close_buy_signal, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), text="CLOSE BUY", title="Close Buy Signal")
plotshape(sell_signal, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), text="SELL", title="Sell Signal")
plotshape(close_sell_signal, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), text="CLOSE SELL", title="Close Sell Signal")