该策略是一个结合了MACD(移动平均收敛散度)和RSI(相对强弱指标)的趋势跟踪交易系统。策略在5分钟时间周期上运行,通过分析MACD与信号线的交叉以及RSI超买超卖水平来产生交易信号。同时集成了基于百分比的止损和获利了结机制,以实现风险管理。
策略主要基于以下核心逻辑: 1. 使用12-26-9参数设置的MACD指标捕捉价格趋势 2. 采用14周期的RSI指标识别超买超卖状态 3. 当MACD线上穿信号线且RSI低于45时,触发做多信号 4. 当MACD线下穿信号线且RSI高于55时,触发平仓信号 5. 设置1.2%止损以控制风险,2.4%止盈以锁定收益 6. 使用10周期EMA作为趋势过滤器,提高信号质量
该策略通过结合MACD和RSI的优势,构建了一个兼具趋势跟踪和动量特性的交易系统。完善的风险控制机制和清晰的交易逻辑使其具有良好的实用性。通过建议的优化方向,策略还有进一步提升空间。在实盘应用时,建议先进行充分的回测验证,并根据具体市场特点适当调整参数。
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-11 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
strategy("MACD + RSI Basit Strateji", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// İndikatör parametreleri
fastLength = input(12, "MACD Fast Length")
slowLength = input(26, "MACD Slow Length")
signalLength = input(9, "MACD Signal Length")
rsiLength = input(14, "RSI Period")
rsiOversold = input(45, "RSI Oversold Level")
rsiOverbought = input(55, "RSI Overbought Level")
// Stop Loss ve Take Profit ekledim
stopLoss = input(1.2, "Stop Loss (%)")
takeProfit = input(2.4, "Take Profit (%)")
// MACD hesaplama
[macdLine, signalLine, histLine] = ta.macd(close, fastLength, slowLength, signalLength)
// RSI hesaplama
rsiValue = ta.rsi(close, rsiLength)
// EMA trend filtresi
emaValue = ta.ema(close, 10)
// Alım sinyali koşulları - sadece MACD ve RSI kullanalım
longCondition = macdLine > signalLine and rsiValue < rsiOversold
// Satım sinyali koşulları
shortCondition = macdLine < signalLine and rsiValue > rsiOverbought
// Pozisyon yönetimi - Stop Loss ve Take Profit ekledim
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("TP/SL", "Long",
profit = close * takeProfit / 100,
loss = close * stopLoss / 100)
if (shortCondition)
strategy.close("Long")
// Grafik göstergeleri
plotshape(longCondition, title="Alım",
style=shape.triangleup,
location=location.belowbar,
color=color.green,
size=size.large,
text="AL")
plotshape(shortCondition, title="Satım",
style=shape.triangledown,
location=location.abovebar,
color=color.red,
size=size.large,
text="SAT")
// İndikatörleri göster
plot(rsiValue, "RSI", color=color.purple)
hline(rsiOversold, "Oversold", color=color.gray)
hline(rsiOverbought, "Overbought", color=color.gray)