This strategy combines three technical indicators: VWAP (Volume Weighted Average Price), RSI (Relative Strength Index), and Bollinger Bands, to implement a simple and easy-to-use quantitative trading strategy with dynamic take profit and stop loss. The main idea of the strategy is to use the VWAP indicator to determine the price trend over a past period, while using the RSI and Bollinger Bands indicators to determine whether the price is in the overbought or oversold range, thus determining the trading signal. Once a trading signal is determined, the strategy calculates dynamic take profit and stop loss levels based on the ATR (Average True Range) indicator to control risk and lock in profits.
This strategy combines three technical indicators: VWAP, RSI, and Bollinger Bands, to implement a simple and easy-to-use quantitative trading strategy. The strategy uses dynamic take profit and stop loss to effectively control risk and lock in profits. Although the strategy has some potential risks, with reasonable parameter settings and continuous optimization, it is believed that the strategy can achieve good results in actual trading.
/*backtest start: 2024-06-06 00:00:00 end: 2024-06-13 00:00:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("VWAP and RSI Strategy", overlay=true) // VWAP calculation vwap = ta.vwap(close) // RSI calculation rsi_length = 16 rsi = ta.rsi(close, rsi_length) // Bollinger Bands calculation bb_length = 14 bb_std = 2.0 [bb_middle, bb_upper, bb_lower] = ta.bb(close, bb_length, bb_std) // Variables for VWAP signal calculation backcandles = 15 float vwapsignal = na // Function to check if last 15 candles are above or below VWAP calc_vwapsignal(backcandles) => upt = true dnt = true for i = 0 to backcandles - 1 if close[i] < vwap[i] upt := false if close[i] > vwap[i] dnt := false if upt and dnt 3 else if upt 2 else if dnt 1 else 0 // Calculate VWAP signal for each bar vwapsignal := calc_vwapsignal(backcandles) // Calculate total signal totalsignal = 0 if vwapsignal == 2 and close <= bb_lower and rsi < 45 totalsignal := 2 else if vwapsignal == 1 and close >= bb_upper and rsi > 55 totalsignal := 1 // Define strategy entry and exit conditions slatr = 1.2 * ta.atr(7) TPSLRatio = 1.5 if (totalsignal == 2 and strategy.opentrades == 0) strategy.entry("Long", strategy.long, stop=close - slatr, limit=close + slatr * TPSLRatio) if (totalsignal == 1 and strategy.opentrades == 0) strategy.entry("Short", strategy.short, stop=close + slatr, limit=close - slatr * TPSLRatio) // Additional exit conditions based on RSI if (strategy.opentrades > 0) if (strategy.position_size > 0 and rsi >= 90) strategy.close("Long") if (strategy.position_size < 0 and rsi <= 10) strategy.close("Short")