
이 전략은 EMA 빠른 선과 느린 선의 골드 포크와 데드 포크를 사용하여 트렌드를 판단하고, 미리 설정된 스톱 스코어 비율과 결합하여 트렌드 추적 거래를 구현한다. 이 전략은 임의의 시간 주기에서 적용되며, 지수와 개별 주식의 트렌드 캡처를 구현할 수 있다.
이 전략은 3와 30의 길이의 EMA선을 거래 신호로 사용합니다. 3EMA 상위에서 30EMA를 넘으면 가격이 상승하기 시작한다는 것을 나타냅니다.
또한, 전략은 정지 조건을 설정한다. 가격 상승이 전략 진입 가격에 따라 설정된 정지 비율에 도달하면, EXIT한다. 이렇게하면 더 많은 이익을 잠금화하고, 트렌드 추적 거래를 가능하게 한다.
이 전략은 전반적으로 매우 실용적인 트렌드 추적 전략이다. 간단한 EMA 지표를 사용하여 트렌드 방향을 판단하고, 합리적인 중지 규칙을 설정하여 위험을 효과적으로 제어하고, 주식 및 지수의 중장선 이동을 추적하는 데 적합하다. 매개 변수 최적화 및 보조 지표 검증을 통해 전략의 안정성과 수익 요소를 더욱 향상시킬 수 있다.
/*backtest
start: 2023-02-12 00:00:00
end: 2024-02-18 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover Strategy with Target", shorttitle="EMACross", overlay=true)
// Define input parameters
fastLength = input(3, title="Fast EMA Length")
slowLength = input(30, title="Slow EMA Length")
profitPercentage = input(100.0, title="Profit Percentage")
// Calculate EMAs
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)
// Plot EMAs on the chart
plot(fastEMA, color=color.blue, title="Fast EMA")
plot(slowEMA, color=color.red, title="Slow EMA")
// Buy condition: 3EMA crosses above 30EMA
buyCondition = ta.crossover(fastEMA, slowEMA)
// Sell condition: 3EMA crosses below 30EMA or profit target is reached
sellCondition = ta.crossunder(fastEMA, slowEMA) or close >= (strategy.position_avg_price * (1 + profitPercentage / 100))
// Target condition: 50 points profit
//targetCondition = close >= (strategy.position_avg_price + 50)
// Execute orders
// strategy.entry("Buy", strategy.long, when=buyCondition)
// strategy.close("Buy", when=sellCondition )
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.close("Buy")
// // Execute sell orders
// strategy.entry("Sell", strategy.short, when=sellCondition)
// strategy.close("Sell", when=buyCondition)
// Plot buy and sell signals on the chart
plotshape(series=buyCondition, title="Buy Signal", color=color.green, style=shape.labelup, location=location.belowbar)
plotshape(series=sellCondition, title="Sell Signal", color=color.red, style=shape.labeldown, location=location.abovebar)