RSI versus SMA (no repaint)
May 23, 2016

The RSI versus SMA (no repaint) indicator provides a comparative analysis between the Relative Strength Index and a Simple Moving Average to identify trend shifts and momentum-based trading opportunities.
Usage
This tool can be used to identify trend changes by observing the relationship between the RSI and its moving average. By default, the indicator plots the RSI and an area-based SMA. Traders can use crossovers between these two components to signal potential entries or exits.
The script also includes a built-in strategy component:
- Trend Direction: The indicator determines trade direction based on whether the RSI is above or below the moving average.
- Bar Coloring: Bars are colored to reflect the current trade direction (Green for bullish/long, Red for bearish/short).
- Trade Inversion: Users can invert the logic if they prefer to trade against the primary momentum signal.
Details
The script addresses the common issue of "repainting" by implementing a calculation shunt. If any source other than the "open" price is selected, the script automatically offsets the calculation by one bar to ensure that the data processed is finalized.
The RSI is calculated with a -50 point shift to center the median at zero, making it easier to visualize momentum relative to a baseline. The "Limit" lines are placed at +25 and -25 to help identify overextended conditions relative to the zero-median.
Settings
Core Settings
- RSI Source: Determines the price source used for the RSI calculation (e.g., Open, Close, HL2).
- RSI Length: Sets the lookback period for the RSI calculation.
- MA Period: Sets the lookback period for the Simple Moving Average applied to the RSI.
- Invert Trade Direction?: When enabled, flips the long/short logic of the strategy.
Strategy & Risk Management
- Use Initial Stop Loss?: Enables a fixed point-based stop loss.
- Initial Stop Loss Points: The distance in points for the fixed stop loss.
- Use Trailing Stop?: Enables a trailing stop mechanism.
- Trail Points: The distance in points the stop should trail the price.
- Use Offset For Trailing Stop?: Enables a trailing stop offset.
- Trail Offset Points: The distance in points for the trailing stop offset.
FAQ
How do I use the RSI versus SMA (no repaint)?
You can use it to identify momentum shifts by watching for crossovers between the RSI line and the SMA area. When the RSI crosses above the SMA, it suggests bullish momentum, while a cross below suggests bearish momentum.
Does this indicator repaint?
No, the script includes a built-in shunt that offsets calculations by one bar when using non-open price sources, ensuring that the signals do not change after the bar has closed.
Where can 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.