该策略结合了MACD(移动平均线收敛背离指标)、RSI(相对强弱指数)和SMA(简单移动平均线)来生成可靠的买卖信号。MACD用于捕捉价格的动量变化,RSI用于识别超买和超卖状态,而SMA用于确认趋势方向。该策略通过多重条件过滤,以减少虚假信号,为日内交易提供明确的进出场点。
该策略的进场和出场条件如下:
该策略通过结合MACD、RSI和SMA等技术指标,形成了一个多重过滤的日内交易策略。它利用动量和趋势的变化来捕捉交易机会,同时通过明确的进出场规则来控制风险。尽管该策略可能在震荡市中面临挑战,但通过进一步优化和风险管理,它有望成为一个可靠的日内交易工具。
/*backtest start: 2024-05-07 00:00:00 end: 2024-06-06 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Day Trading Strategy", overlay=true) // Parametrii pentru MACD macdLength = input.int(12, title="MACD Length") signalSmoothing = input.int(9, title="MACD Signal Smoothing") src = input(close, title="Source") // Calculul MACD [macdLine, signalLine, _] = ta.macd(src, macdLength, 26, signalSmoothing) macdHist = macdLine - signalLine // Parametrii pentru RSI rsiLength = input.int(14, title="RSI Length") rsiOverbought = input.int(70, title="RSI Overbought Level") rsiOversold = input.int(30, title="RSI Oversold Level") // Calculul RSI rsi = ta.rsi(src, rsiLength) // Filtru suplimentar pentru a reduce semnalele false longFilter = ta.sma(close, 50) > ta.sma(close, 200) shortFilter = ta.sma(close, 50) < ta.sma(close, 200) // Conditii de intrare in pozitie long enterLong = ta.crossover(macdLine, signalLine) and rsi < rsiOverbought and longFilter // Conditii de iesire din pozitie long exitLong = ta.crossunder(macdLine, signalLine) or rsi > rsiOverbought // Conditii de intrare in pozitie short enterShort = ta.crossunder(macdLine, signalLine) and rsi > rsiOversold and shortFilter // Conditii de iesire din pozitie short exitShort = ta.crossover(macdLine, signalLine) or rsi < rsiOversold // Adaugarea strategiei pentru Strategy Tester if (enterLong) strategy.entry("BUY", strategy.long) if (exitLong) strategy.close("BUY") if (enterShort) strategy.entry("SELL", strategy.short) if (exitShort) strategy.close("SELL") // Plotarea MACD si Signal Line plot(macdLine, color=color.blue, title="MACD Line") plot(signalLine, color=color.orange, title="Signal Line") hline(0, "Zero Line", color=color.gray) plot(macdHist, color=color.red, style=plot.style_histogram, title="MACD Histogram")