这是一个结合了Supertrend、指数移动平均线(EMA)和相对强弱指标(RSI)的多指标交易策略。策略通过这三个技术指标的交叉信号和超买超卖水平来识别市场趋势、动量和潜在的反转点,从而在市场中寻找理想的交易机会。该策略充分利用了多个指标的优势,通过不同维度的市场分析来提高交易的准确性和可靠性。
策略的核心逻辑基于三个主要技术指标的组合分析: 1. Supertrend指标用于确定整体趋势方向,利用ATR波动率来动态调整趋势线。 2. 短期(9周期)和长期(21周期)EMA的交叉用于捕捉价格动量的变化。 3. RSI指标用于识别市场是否处于超买或超卖状态。
买入信号需要同时满足以下条件: - Supertrend指标显示多头趋势(价格位于Supertrend线上方) - 短期EMA向上穿过长期EMA - RSI未达到超买水平(低于70)
卖出信号需要同时满足以下条件: - Supertrend指标显示空头趋势(价格位于Supertrend线下方) - 短期EMA向下穿过长期EMA - RSI未达到超卖水平(高于30)
这是一个结构完整、逻辑清晰的多指标量化交易策略,通过结合趋势跟踪、动量分析和超买超卖指标,构建了一个相对全面的交易系统。策略的优势在于多指标交叉验证提高了信号可靠性,同时具有清晰的风险控制机制。虽然存在一些固有的风险,但通过持续优化和完善,策略有望在不同市场环境下保持稳定的表现。
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © satyakipaul3744
//@version=6
//@version=6
strategy("Supertrend + EMA Crossover + RSI Strategy", overlay=true)
// --- Input Parameters ---
supertrend_length = input.int(10, title="Supertrend Length", minval=1)
supertrend_multiplier = input.float(3.0, title="Supertrend Multiplier", step=0.1)
short_ema_length = input.int(9, title="Short EMA Length")
long_ema_length = input.int(21, title="Long EMA Length")
rsi_length = input.int(14, title="RSI Length")
rsi_overbought = input.int(70, title="RSI Overbought Level")
rsi_oversold = input.int(30, title="RSI Oversold Level")
// --- Indicator Calculations ---
// Supertrend calculation
[supertrend, direction] = ta.supertrend(supertrend_multiplier, supertrend_length)
// EMA calculations
short_ema = ta.ema(close, short_ema_length)
long_ema = ta.ema(close, long_ema_length)
// RSI calculation
rsi = ta.rsi(close, rsi_length)
// --- Buy/Sell Conditions ---
// Buy condition: Supertrend bullish, EMA crossover, RSI not overbought
buy_condition = direction > 0 and ta.crossover(short_ema, long_ema) and rsi < rsi_overbought
// Sell condition: Supertrend bearish, EMA crossunder, RSI not oversold
sell_condition = direction < 0 and ta.crossunder(short_ema, long_ema) and rsi > rsi_oversold
// --- Plot Buy/Sell signals ---
plotshape(buy_condition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sell_condition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// --- Strategy Orders for Backtesting ---
if buy_condition
strategy.entry("Buy", strategy.long)
if sell_condition
strategy.close("Buy")
// --- Plot Supertrend ---
plot(supertrend, color=direction > 0 ? color.green : color.red, linewidth=2, title="Supertrend")
// --- Plot EMAs ---
plot(short_ema, color=color.blue, title="Short EMA")
plot(long_ema, color=color.orange, title="Long EMA")
// --- Strategy Performance ---
// You can see the strategy performance in the "Strategy Tester" tab.