OPEN-SOURCE SCRIPT

WEN - SMA with RSI Strategy

214
SMA with RSI Trading Strategy Description

The "SMA with RSI Strategy" is a technical analysis-based trading bot designed to identify potential entry and exit points in financial markets using a combination of Simple Moving Averages (SMA) and the Relative Strength Index (RSI). This strategy blends trend-following and momentum-filtering techniques to create a balanced approach suitable for various market conditions.

Key Features:
1. **Dual SMA Crossover System**:
- Utilizes two Simple Moving Averages with customizable periods:
- Short MA (default: 9 periods) – Faster-moving average to capture short-term price trends.
- Long MA (default: 21 periods) – Slower-moving average to identify longer-term trends.
- Generates buy signals when the Short MA crosses above the Long MA (bullish crossover).
- Generates sell signals when the Short MA crosses below the Long MA (bearish crossover).

2. **RSI Confirmation**:
- Incorporates the Relative Strength Index (default length: 14 periods) to filter trades and avoid overextended market conditions.
- Configurable overbought (default: 70) and oversold (default: 30) thresholds.
- Long entries are only executed if RSI is below the overbought level, preventing buys in potentially overextended upward moves.
- Short entries are only executed if RSI is above the oversold level, avoiding shorts in potentially overextended downward moves.

3. **Risk Management**:
- Built-in stop loss (default: 1%) and take profit (default: 2%) levels, calculated as percentages of the entry price.
- Automatically exits positions when either the stop loss or take profit is hit, helping to manage risk and lock in gains.

Trading Logic:
- **Long Entry**: Triggers when the Short MA crosses above the Long MA and RSI is below the overbought threshold, indicating a potential upward trend with room to grow.
- **Short Entry**: Triggers when the Short MA crosses below the Long MA and RSI is above the oversold threshold, signaling a potential downward trend with room to fall.
- **Exit**: Closes positions based on predefined stop loss or take profit levels, or when a short signal closes an existing long position.

Visual Indicators:
- Plots the Short MA (blue) and Long MA (red) on the price chart for easy trend visualization.
- RSI is typically displayed in a separate panel (platform-dependent) to monitor momentum.

Customization:
- All key parameters (MA lengths, RSI period, overbought/oversold levels, stop loss, and take profit) are adjustable, allowing traders to optimize the strategy for different markets, timeframes, and risk preferences.

Ideal Use Cases:
- Best suited for trending markets where SMA crossovers can capture sustained price movements.
- The RSI filter helps reduce false signals in choppy or ranging markets.
- Applicable to various asset classes (stocks, forex, cryptocurrencies, etc.) with proper parameter tuning.

This strategy offers a straightforward yet effective approach to automated trading, combining trend-following with momentum confirmation while maintaining robust risk management controls.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.