
이것은 EMA 지표를 기반으로 한 양적 거래 전략이며, 단기 (<9주기>) 과 장기 (<21주기>) 지수 이동 평균의 교차 신호를 계산하여 거래 결정을 내립니다. 전략은 위험을 제어하고 수익을 잠금하기 위해 각각 2%와 4%의 중지 및 중지 조건을 설정합니다. 이 전략의 핵심 아이디어는 평행선 교차점을 활용하여 시장 추세의 전환점을 포착하여 시장 추세가 변경될 때 구매 및 판매 작업을 수행하는 것입니다.
이 전략은 두 개의 다른 주기의 지수 이동 평균 (((EMA) 을 사용한다. 각각 9주기 및 21주기이다. 단기 EMA가 상향으로 장기 EMA를 통과하면 구매 신호를 발생시키고, 단기 EMA가 하향으로 장기 EMA를 통과하면 판매 신호를 발생시킨다. 전략은 또한 위험 관리 메커니즘을 포함하고 있으며, 2%의 스톱 손실과 4%의 스톱을 설정하여 자금을 안전하게 보호하고 수익을 잠금시킨다. 단기 평균선은 가격 변화에 더 민감한 반면, 장기 평균선은 더 장기적인 추세를 반영할 수 있으며, 둘의 교차는 시장 추세의 전환점을 더 잘 포착한다.
이 전략은 고전적인 트렌드 추적 전략으로, 평행선 교차로 시장 트렌드 변화를 포착한다. 전략 설계는 비교적 간단하지만, 완전한 거래 논리와 위험 제어 메커니즘을 포함하고 있다. 동적 파라미터 조정, 시장 환경 판단 등의 최적화 조치를 추가함으로써 전략의 안정성과 수익성을 더욱 높일 수 있다. 실제 응용에서는 특정 거래 유형과 시장 환경에 따라 파라미터 최적화를 권장하며, 위험 제어에 주의를 기울인다.
/*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"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ancour
//@version=5
strategy("Moving Average Crossover", overlay=true)
// Define the length for short-term and long-term EMAs
shortEmaLength = 9
longEmaLength = 21
// Calculate EMAs
shortEma = ta.ema(close, shortEmaLength)
longEma = ta.ema(close, longEmaLength)
// Plot EMAs on the chart
plot(shortEma, title="Short-term EMA", color=color.green, linewidth=2)
plot(longEma, title="Long-term EMA", color=color.red, linewidth=2)
// Strategy conditions for crossovers
longCondition = ta.crossover(shortEma, longEma)
shortCondition = ta.crossunder(shortEma, longEma)
// Enter long when short EMA crosses above long EMA
if (longCondition)
strategy.entry("Buy", strategy.long)
// Exit long or enter short when short EMA crosses below long EMA
if (shortCondition)
strategy.entry("Sell", strategy.short)
// Optional: Add stop-loss and take-profit levels for risk management
stopLossPercent = 2
takeProfitPercent = 4
strategy.exit("Sell TP/SL", "Buy", stop=low * (1 - stopLossPercent/100), limit=high * (1 + takeProfitPercent/100))