该策略是一个基于多重均线系统和RSI指标的趋势跟踪策略。策略采用20、50和200周期的移动平均线组合,通过分析不同均线之间的位置关系来判断市场趋势,并结合RSI指标进行交易信号的确认。策略设置了动态止损和盈利目标,通过追踪止损的方式来保护已获得的利润。
策略的核心是通过分析三条均线(MA20、MA50、MA200)之间的相对位置关系来确定市场趋势。策略定义了18种不同的均线组合场景,主要关注均线交叉和位置关系。当短期均线位于长期均线之上时,倾向于做多;反之则倾向于做空。为了避免过度交易,策略引入了RSI指标作为过滤条件,当RSI低于70时允许做多,高于30时允许做空。策略采用了1:10的风险收益比设置,并使用25点的追踪止损来保护盈利。
这是一个结构完整、逻辑清晰的趋势跟踪策略。通过多重均线系统的配合使用,结合RSI指标的过滤,形成了一个相对可靠的交易系统。策略的风险管理机制设计合理,通过追踪止损的方式既保护了利润又不会过早离场。虽然策略还存在一些需要优化的空间,但整体框架设计较为科学,具有实际应用价值。
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Refined MA Strategy with Trailing Stop for 30m", overlay=true)
// Define the moving averages
TR20 = ta.sma(close, 20)
TR50 = ta.sma(close, 50)
TR200 = ta.sma(close, 200)
// Define the RSI for additional filtering
rsi = ta.rsi(close, 14)
// Define the scenarios
scenario1 = TR20 > TR50 and TR50 > TR200
scenario2 = TR50 > TR20 and TR20 > TR200
scenario3 = TR200 > TR50 and TR50 > TR20
scenario4 = TR50 > TR200 and TR200 > TR20
scenario5 = TR20 > TR200 and TR200 > TR50
scenario6 = TR200 > TR20 and TR20 > TR50
scenario7 = TR20 == TR50 and TR50 > TR200
scenario8 = TR50 == TR20 and TR20 > TR200
scenario9 = TR200 == TR50 and TR50 > TR20
scenario10 = TR20 > TR50 and TR50 == TR200
scenario11 = TR50 > TR20 and TR20 == TR200
scenario12 = TR20 > TR50 and TR50 == TR200
scenario13 = TR20 == TR50 and TR50 == TR200
scenario14 = TR20 > TR50 and TR200 == TR50
scenario15 = TR50 > TR20 and TR200 == TR50
scenario16 = TR20 > TR50 and TR50 == TR200
scenario17 = TR20 > TR50 and TR50 == TR200
scenario18 = TR20 > TR50 and TR50 == TR200
// Entry conditions
longCondition = (scenario1 or scenario2 or scenario5) and rsi < 70
shortCondition = (scenario3 or scenario4 or scenario6) and rsi > 30
// Execute trades based on scenarios with 50 points stop loss and 1:10 RR, using a trailing stop of 25 points
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit", from_entry="Long", limit=close + 250, trail_offset=25)
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit", from_entry="Short", limit=close - 250, trail_offset=25)