This strategy is a multi-signal trend following system based on dual moving averages and the Relative Strength Index (RSI). Operating on a 1-hour timeframe, it identifies market trends and trading opportunities through crossovers of short-term and long-term moving averages, combined with RSI overbought and oversold levels. The system employs a combination of 9-period and 21-period Simple Moving Averages (SMA) along with a 14-period RSI to create a comprehensive trend following and momentum confirmation trading system.
The core logic of the strategy is based on the following key elements: 1. Uses 9-period and 21-period Simple Moving Averages to identify trend direction, with long signals generated when the short MA crosses above the long MA, and short signals when it crosses below. 2. Incorporates RSI as a trend confirmation tool, with 70 and 30 set as overbought and oversold thresholds. 3. When moving average crossovers occur, the system checks if RSI values meet corresponding conditions: long positions require RSI above oversold level (30), short positions require RSI below overbought level (70). 4. Trades are executed only when both moving average crossover and RSI conditions are satisfied simultaneously.
This strategy constructs a relatively complete trend following trading system by combining moving average systems with RSI indicators. The strategy design philosophy emphasizes signal reliability and risk control, suitable for medium to long-term trend trading. While there are some inherent limitations, the overall performance of the strategy can be further improved through the suggested optimization directions. The code implementation is professional and standardized, with good scalability, making it a trading system worthy of in-depth study and practice.
/*backtest start: 2019-12-23 08:00:00 end: 2025-01-16 00:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}] */ // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Vitaliby //@version=5 strategy("Vitaliby MA and RSI Strategy", overlay=true) // Входные параметры для настройки shortMALength = input.int(9, title="Short MA Length") longMALength = input.int(21, title="Long MA Length") rsiLength = input.int(14, title="RSI Length") rsiOverbought = input.int(70, title="RSI Overbought Level") rsiOversold = input.int(30, title="RSI Oversold Level") // Расчет скользящих средних и RSI shortMA = ta.sma(close, shortMALength) longMA = ta.sma(close, longMALength) rsi = ta.rsi(close, rsiLength) // Определение условий для входа и выхода longCondition = ta.crossover(shortMA, longMA) and rsi > rsiOversold shortCondition = ta.crossunder(shortMA, longMA) and rsi < rsiOverbought // Отображение сигналов на графике plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small) plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small) // Отображение скользящих средних на графике plot(shortMA, color=color.blue, title="Short MA") plot(longMA, color=color.orange, title="Long MA") // Отображение RSI на отдельном окне hline(rsiOverbought, "Overbought", color=color.red) hline(rsiOversold, "Oversold", color=color.green) plot(rsi, color=color.purple, title="RSI") // Управление позициями if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.close("Long") if (shortCondition) strategy.entry("Short", strategy.short) if (longCondition) strategy.close("Short")