
이 전략은 110일과 200일 지수 이동 평균 ((EMA) 의 교차를 기반으로 한 트렌드 추적 거래 시스템이다. 전략은 단기 EMA와 장기 EMA의 교차를 관찰하여 시장의 흐름을 판단하고, 손해 차단 장치와 결합하여 위험을 제어한다. 시스템은 트렌드 신호를 확인한 후, 자동으로 적절한 다중 거래 작업을 수행하며, 실시간으로 포지션 위험을 모니터링한다.
전략의 핵심 논리는 가격 트렌드의 연속성을 기반으로 EMA110과 EMA200의 교차를 통해 트렌드 전환 신호를 포착한다. 단기 평균선 (EMA110) 위를 장기 평균선 (EMA200) 을 통과하면 상승 추세가 형성되는 것을 나타내는 시스템에서 여러 신호를 발산한다. 단기 평균선 아래를 통과하면 하향 추세가 형성되는 것을 나타내는 시스템에서 빈 신호를 발산한다. 위험을 제어하기 위해, 전략은 매번 포지션 개시 시 동시에 1%의 스톱 손실과 0.5%의 스톱 손실을 설정하여 수익을 보호하고 가능한 손실을 제한한다.
이 전략은 평선 교차 트렌드를 포착하고, 손해 중지 장치와 결합하여 위험을 관리합니다. 전체적으로 설계되어 합리적이며, 논리적으로 엄격합니다. 불안정한 시장에서 좋지 않은 성능을 보일 수 있지만, 제안된 최적화 방향을 통해 전략의 안정성과 수익성을 더욱 향상시킬 수 있습니다. 전략은 안정적인 수익을 추구하는 중장기 투자자에게 적합합니다.
/*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("EMA110/200 Cross with Stop-Loss and Take-Profit", overlay=true)
// 定义EMA110和EMA200
ema110 = ta.ema(close, 110)
ema200 = ta.ema(close, 250)
// 画出EMA
plot(ema110, color=color.blue, title="EMA110")
plot(ema200, color=color.red, title="EMA200")
// 计算交叉信号
longCondition = ta.crossover(ema110, ema200) // EMA110上穿EMA200,做多
shortCondition = ta.crossunder(ema110, ema200) // EMA110下穿EMA200,做空
// 设置止损和止盈
stopLoss = 0.01 // 止损1%
takeProfit = 0.005 // 止盈0.5%
// 判断是否已有仓位
isLong = strategy.position_size > 0 // 当前是否为多头仓位
isShort = strategy.position_size < 0 // 当前是否为空头仓位
// 执行策略:做多时平空,做空时平多
if (longCondition and not isLong) // 如果满足做多条件并且当前没有多头仓位
if (isShort) // 如果当前是空头仓位,先平空
strategy.close("Short")
strategy.entry("Long", strategy.long) // 执行做多
strategy.exit("Take Profit/Stop Loss", "Long", stop=close * (1 - stopLoss), limit=close * (1 + takeProfit))
if (shortCondition and not isShort) // 如果满足做空条件并且当前没有空头仓位
if (isLong) // 如果当前是多头仓位,先平多
strategy.close("Long")
strategy.entry("Short", strategy.short) // 执行做空
strategy.exit("Take Profit/Stop Loss", "Short", stop=close * (1 + stopLoss), limit=close * (1 - takeProfit))
// 在表格中显示信号
var table myTable = table.new(position.top_right, 1, 1)
if (longCondition and not isLong)
table.cell(myTable, 0, 0, "Buy Signal", text_color=color.green)
if (shortCondition and not isShort)
table.cell(myTable, 0, 0, "Sell Signal", text_color=color.red)