This strategy combines multiple indicators such as EMA, MACD, VWAP, and RSI to capture high-probability trading opportunities. It uses EMA to determine the trend direction, MACD for momentum, VWAP for volume, and RSI for overbought and oversold conditions. The strategy generates buy and sell signals based on a combination of these indicators while using a trailing stop loss to protect profits.
This strategy combines multiple indicators to assess market conditions and generate trading signals while using a trailing stop loss to protect profits. Strategy parameters can be adjusted according to user preferences, enhancing the flexibility of the strategy. However, the strategy may perform poorly in choppy markets and face larger drawdowns during trend reversals, so it needs to be optimized and improved for different markets and instruments. Future optimizations can consider adding more filtering conditions, dynamic stop loss methods, parameter optimization, and position sizing to improve the stability and profitability of the strategy.
/*backtest start: 2024-04-01 00:00:00 end: 2024-04-30 23:59:59 period: 4h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Intraday Strategy", overlay=true) // Input parameters emaLength = input.int(50, title="EMA Length") macdShort = input.int(12, title="MACD Short Period") macdLong = input.int(26, title="MACD Long Period") macdSignal = input.int(9, title="MACD Signal Period") rsiLength = input.int(14, title="RSI Length") rsiOverbought = input.int(70, title="RSI Overbought Level") rsiOversold = input.int(30, title="RSI Oversold Level") risk = input.float(1, title="Risk Percentage", minval=0.1, step=0.1) trailOffset = input.float(0.5, title="Trailing Stop Offset", minval=0.1, step=0.1) // Calculating indicators ema = ta.ema(close, emaLength) [macdLine, signalLine, _] = ta.macd(close, macdShort, macdLong, macdSignal) rsi = ta.rsi(close, rsiLength) vwap = ta.vwap(close) // Entry conditions longCondition = ta.crossover(macdLine, signalLine) and close > ema and rsi < rsiOverbought and close > vwap shortCondition = ta.crossunder(macdLine, signalLine) and close < ema and rsi > rsiOversold and close < vwap // Exit conditions longExitCondition = ta.crossunder(macdLine, signalLine) or close < ema shortExitCondition = ta.crossover(macdLine, signalLine) or close > ema // Position sizing based on risk percentage capital = strategy.equity positionSize = (capital * (risk / 100)) / close // Executing trades if (longCondition) strategy.entry("Long", strategy.long, qty=1) if (shortCondition) strategy.entry("Short", strategy.short, qty=1) if (longExitCondition) strategy.close("Long") if (shortExitCondition) strategy.close("Short") // Trailing stop loss if (strategy.position_size > 0) strategy.exit("Trailing Stop Long", from_entry="Long", trail_price=close, trail_offset=trailOffset) if (strategy.position_size < 0) strategy.exit("Trailing Stop Short", from_entry="Short", trail_price=close, trail_offset=trailOffset) // Plotting indicators plot(ema, title="EMA", color=color.blue) hline(rsiOverbought, "Overbought", color=color.red) hline(rsiOversold, "Oversold", color=color.green) plot(rsi, title="RSI", color=color.purple) plot(vwap, title="VWAP", color=color.orange)