
该策略是一个基于200周期简单移动平均线(MA200)的趋势跟踪系统,结合了相对强弱指标(RSI)、平均趋向指数(ADX)和平均真实波幅(ATR)等技术指标,形成了一个完整的交易决策框架。策略通过动态止损和获利目标的设置,实现了风险的有效控制。从回测结果来看,该策略在多个交易品种上都取得了较好的胜率,展现出较强的适应性和稳定性。
策略的核心逻辑建立在以下几个关键点上: 1. 使用MA200作为主要趋势判断指标,当价格突破MA200时产生初始信号 2. 采用RSI指标进行超买超卖判断,买入信号要求RSI>40,卖出信号要求RSI<60 3. 引入ADX指标判断趋势强度,要求ADX>20以确保趋势明确 4. 通过2个周期的信号确认来过滤假突破 5. 基于ATR设置动态止损,take profit固定为2%
该策略通过结合多个技术指标,构建了一个稳健的趋势跟踪系统。策略在设计上注重了风险控制,通过动态止损和信号确认机制来提高交易的可靠性。虽然存在一些优化空间,但整体而言是一个具有实用价值的交易策略。后续可以通过参数优化和增加辅助指标来进一步提升策略的表现。
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"TRB_USDT"}]
*/
//@version=5
strategy("BTC/USD MA200 with RSI, ADX, ATR", overlay=true)
// Definition of the main moving average
ma_trend = ta.sma(close, 200) // Main trend filter
// Definition of RSI and ADX
rsi = ta.rsi(close, 14)
[diplus, diminus, adx] = ta.dmi(14, 14) // Correction for ADX
// Definition of ATR for Stop Loss and Take Profit
atr = ta.atr(14)
// Conditions for crossing of the MA200
crossover_condition = ta.crossover(close, ma_trend)
crossunder_condition = ta.crossunder(close, ma_trend)
// Trend confirmation after 2 bars
buy_confirmation = crossover_condition[2] and (rsi > 40) and (adx > 20) and close > ma_trend
sell_confirmation = crossunder_condition[2] and (rsi < 60) and (adx > 20) and close < ma_trend
// Definition of Stop Loss and Take Profit
take_profit = close * 1.02 // 2% profit
stop_loss = close - (1.5 * atr) // Dynamic stop based on ATR
// Execution of orders
if (buy_confirmation and strategy.opentrades == 0)
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit/Stop Loss", from_entry="Buy", limit=take_profit, stop=stop_loss)
label.new(bar_index, high, "BUY", style=label.style_label_down, color=color.green, textcolor=color.white, size=size.normal)
if (sell_confirmation)
if (strategy.opentrades > 0)
strategy.close("Buy")
label.new(bar_index, low, "SELL", style=label.style_label_up, color=color.red, textcolor=color.white, size=size.normal)
// Draw the main moving average
plot(ma_trend, color=color.purple, title="MA 200")