RSI Strategy
Jan 18, 2022

The RSI Strategy tool provides a comprehensive backtesting framework designed to execute trades based on Relative Strength Index (RSI) levels, offering both trend-following and mean-reversion logic.
Usage
The strategy can be utilized in two primary modes:
- Standard RSI Logic: Executes long positions when the RSI is overbought and short positions when it is oversold.
- Reversed RSI Logic: Executes short positions when the RSI is overbought and long positions when it is oversold.
Users can refine entries by enabling an EMA filter, ensuring trades are only taken when the price is on the appropriate side of the moving average. Additionally, the strategy supports session-based trading, allowing users to define specific hours for trade execution and automatically close positions at the end of the session, which is particularly useful for day trading.
Details
The strategy calculates the RSI based on a user-defined length and source. If the EMA filter is active, it compares the current closing price to the EMA to confirm trend alignment. For risk management, the script calculates percentage-based Stop Loss and Take Profit levels from the average position price. It also includes a time-conditional filter to restrict backtesting to a specific date range.
Settings
RSI & Backtesting
- Backtesting Start/End Date: Defines the time range for the strategy to run.
- RSI Length: The lookback period for the RSI calculation.
- Overbought/Oversold Level: The threshold levels for signal generation.
- RSI Logic Toggles: Options to switch between standard and flipped entry conditions.
Filters & Session
- EMA Settings: Toggles for the EMA filter, including length and source inputs.
- Time Frame To Enter Trades: A session string (e.g., "0930-1600") to limit trading hours.
- Enable Close Trade At End Of Time Frame: Closes all active trades when the specified session ends.
Risk Management & Alerts
- Enable Stop Loss/Take Profit: Toggles for fixed percentage-based exits.
- Stop Loss/Take Profit %: Sets the distance for exit orders.
- Custom Alert Messages: Fields to input specific strings for entry and exit notifications, compatible with
{{strategy.order.alert_message}}.
FAQ
How do I use the RSI Strategy?
You can apply the strategy to any chart and configure the RSI levels and logic (Standard or Flipped) within the settings menu to match your trading style.
Can I automate this strategy?
Yes, the script includes custom alert fields for long/short entries and exits. By using the {{strategy.order.alert_message}} placeholder in your TradingView alert, you can send these messages to external automated trading services.
How do I access this tool?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.