This strategy is a quantitative trading system that combines Simple Moving Averages (SMA) and Relative Strength Index (RSI). It determines trading opportunities by observing the crossover signals of short-term and long-term moving averages while considering RSI overbought and oversold levels. The strategy is written in Pine Script for the TradingView platform, enabling automated trading and graphical display.
The core logic is based on the combination of two main technical indicators. First, the system calculates 50-period and 200-period Simple Moving Averages (SMA), using their crossovers as primary trend signals. Second, it incorporates a 14-period RSI indicator with 70 and 30 as overbought and oversold thresholds to filter trading signals. A long position is initiated when the short-term MA crosses above the long-term MA and RSI is below the overbought level. The position is closed when the short-term MA crosses below the long-term MA and RSI is above the oversold level.
This strategy constructs a relatively robust trading system through the dual filtering mechanism of MA crossovers and RSI overbought/oversold levels. It is suitable for trending markets but requires parameter adjustment based on specific market characteristics. The strategy’s stability can be further enhanced by adding more filtering conditions and risk control mechanisms. Before live trading, it is recommended to conduct thorough backtesting and optimize parameters according to actual market conditions.
/*backtest start: 2019-12-23 08:00:00 end: 2024-11-27 00:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Chỉ báo Giao dịch Cắt SMA với RSI", overlay=true) // Định nghĩa các tham số short_period = input.int(50, title="Thời gian SMA ngắn") long_period = input.int(200, title="Thời gian SMA dài") rsi_period = input.int(14, title="Thời gian RSI") rsi_overbought = input.int(70, title="Ngưỡng RSI Mua Quá Mức") rsi_oversold = input.int(30, title="Ngưỡng RSI Bán Quá Mức") // Tính toán các SMA sma_short = ta.sma(close, short_period) sma_long = ta.sma(close, long_period) // Tính toán RSI rsi = ta.rsi(close, rsi_period) // Điều kiện vào lệnh Mua (Cắt lên và RSI không quá mua) long_condition = ta.crossover(sma_short, sma_long) and rsi < rsi_overbought // Điều kiện vào lệnh Bán (Cắt xuống và RSI không quá bán) short_condition = ta.crossunder(sma_short, sma_long) and rsi > rsi_oversold // Vẽ các đường SMA và RSI lên biểu đồ plot(sma_short, color=color.blue, title="SMA Ngắn") plot(sma_long, color=color.red, title="SMA Dài") hline(rsi_overbought, "Overbought", color=color.red) hline(rsi_oversold, "Oversold", color=color.green) plot(rsi, color=color.orange, title="RSI") // Hiển thị tín hiệu vào lệnh plotshape(series=long_condition, location=location.belowbar, color=color.green, style=shape.labelup, title="Tín hiệu Mua", text="MUA") plotshape(series=short_condition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Tín hiệu Bán", text="BÁN") // Giao dịch tự động bằng cách sử dụng cấu trúc if if (long_condition) strategy.entry("Long", strategy.long) if (short_condition) strategy.close("Long")