This strategy is a trend-following trading system based on the crossover of 110-day and 200-day Exponential Moving Averages (EMA). It identifies market trends through the intersection of short-term and long-term EMAs, incorporating stop-loss and take-profit mechanisms for risk control. The system automatically executes long and short positions upon trend confirmation while continuously monitoring position risk.
The core logic relies on the continuity of price trends, using EMA110 and EMA200 crossovers to capture trend reversal signals. When the shorter-term moving average (EMA110) crosses above the longer-term moving average (EMA200), it signals an uptrend formation, triggering a long position. Conversely, when the shorter-term moving average crosses below the longer-term moving average, it signals a downtrend formation, triggering a short position. For risk management, the strategy sets a 1% stop-loss and 0.5% take-profit level for each position to protect profits and limit potential losses.
The strategy captures trends through moving average crossovers while managing risk through stop-loss and take-profit mechanisms, demonstrating sound design and logical rigor. Although it may underperform in ranging markets, the suggested optimizations can further enhance strategy stability and profitability. The strategy is suitable for medium to long-term investors seeking steady returns.
/*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)