
이 전략은 쌍평선 시스템을 기반으로 한 자기 적응 거래 전략으로, 빠른 이동 평균 ((EMA25) 과 느린 이동 평균 ((EMA100) 의 교차를 통해 구매 신호를 식별하고, 동적인 중단 손실과 수익 목표와 결합하여 거래 효과를 최적화한다. 이 전략은 획기적인 거래 사고방식을 채택하고, 수익을 보장하면서 위험 통제에 초점을 맞추고, 중장기 트렌드 거래에 적합하다.
전략의 핵심 논리는 세 가지 핵심 부분으로 이루어져 있습니다.
이 전략은 동적 스톱로스 및 이익 관리 메커니즘과 함께 동선 교차 트렌드 시작 지점을 캡처하여 좋은 리스크 수익 특성을 달성합니다. 전략 설계는 실전 요구를 충분히 고려하고 실용성이 강합니다. 제안 된 최적화 방향을 통해 전략의 안정성과 적응력을 더욱 향상시킬 수 있습니다. 전략은 강력한 위험 감수성을 가지고 중·장기 안정적인 수익을 추구하는 거래자의 사용에 적합합니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover with TP and SL (Buy only) and Break-even", overlay=true)
// EMA sozlamalari
emaFastLength = input.int(25, title="Fast EMA Length")
emaSlowLength = input.int(100, title="Slow EMA Length")
// Hisoblash
emaFast = ta.ema(close, emaFastLength)
emaSlow = ta.ema(close, emaSlowLength)
// Kesishishni aniqlash
bullishCross = ta.crossover(emaFast, emaSlow) // EMA 25 EMA 100 ni yuqoriga kesib o'tganda
// EMA 100 tagidagi oxirgi qizil shamning tagini olish
lastRedCandleLow = ta.valuewhen(close < open and close < emaSlow, low, 0) // EMA 100 pastidagi qizil shamning tagi
// TP va SL darajalarini hisoblash
longSL = lastRedCandleLow
longTP = close + 3 * (close - longSL) // TP SL ga nisbatan 1:2 masofada
// Savdoni ochish va 2% foyda bo'lganda SLni break-even ga o‘zgartirish
if (bullishCross)
strategy.entry("Buy", strategy.long) // Buy pozitsiyasini ochish
strategy.exit("Exit Buy", "Buy", stop=longSL, limit=longTP) // SL va TP qo'yish
// 2% foyda bo'lganda SLni break-even ga o'zgartirish
if (strategy.position_size > 0)
profitPercentage = (close - strategy.position_avg_price) / strategy.position_avg_price * 100
if (profitPercentage >= 2)
strategy.exit("Exit Buy BE", "Buy", stop=strategy.position_avg_price) // SLni break-even ga o'zgartirish
// Signalni ko'rsatish
plotshape(bullishCross, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
// // TP va SL chizish
// if (bullishCross)
// line.new(x1=bar_index, y1=longSL, x2=bar_index+1, y2=longSL, color=color.red, width=1, extend=extend.none)
// line.new(x1=bar_index, y1=longTP, x2=bar_index+1, y2=longTP, color=color.green, width=1, extend=extend.none)
// label.new(bar_index, longSL, text="SL: " + str.tostring(longSL), style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small)
// label.new(bar_index, longTP, text="TP: " + str.tostring(longTP), style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small)
// EMA chizish
plot(emaFast, color=color.blue, title="Fast EMA (25)")
plot(emaSlow, color=color.orange, title="Slow EMA (100)")
// Alert qo'shish
alertcondition(bullishCross, title="Buy Signal Alert", message="EMA 25 crossed above EMA 100! Buy Signal!")