OPEN-SOURCE SCRIPT
RSI Mean Reversion

This is classic Mean Reversion Strategy. I use this on commodities.
This strategy trades mean reversion signals based on the Relative Strength Index (RSI). It is designed for volatile, mean-reverting instruments where price tends to snap back after reaching extreme levels.
How it works:
The strategy enters a long position when RSI crosses back above the oversold level, signalling that the selling pressure is fading and price is beginning to recover. It enters a short position when RSI crosses back below the overbought level, signalling that buying pressure is weakening and price is starting to pull back. Positions are reversed — a long is closed when a short signal fires and vice versa.
Key feature: Signals trigger when RSI re-enters the normal channel from an extreme zone, not when it first enters the extreme zone. This provides confirmation that the reversal has begun rather than catching a falling knife.
Recommended usage: This strategy works best on volatile instruments that exhibit mean-reverting behaviour, such as Natural Gas futures on the 4-hour timeframe. A short RSI period (3-5) with oversold levels around 30-40 and overbought levels around 70-80 is a good starting point. Optimise the parameters for your specific instrument using backtesting.
Settings: RSI period, oversold level, overbought level, trade direction (Long Only / Short Only / Both), and bar confirmation toggle are all configurable from the settings panel. Alerts are built in for both buy and sell signals.
This strategy trades mean reversion signals based on the Relative Strength Index (RSI). It is designed for volatile, mean-reverting instruments where price tends to snap back after reaching extreme levels.
How it works:
The strategy enters a long position when RSI crosses back above the oversold level, signalling that the selling pressure is fading and price is beginning to recover. It enters a short position when RSI crosses back below the overbought level, signalling that buying pressure is weakening and price is starting to pull back. Positions are reversed — a long is closed when a short signal fires and vice versa.
Key feature: Signals trigger when RSI re-enters the normal channel from an extreme zone, not when it first enters the extreme zone. This provides confirmation that the reversal has begun rather than catching a falling knife.
Recommended usage: This strategy works best on volatile instruments that exhibit mean-reverting behaviour, such as Natural Gas futures on the 4-hour timeframe. A short RSI period (3-5) with oversold levels around 30-40 and overbought levels around 70-80 is a good starting point. Optimise the parameters for your specific instrument using backtesting.
Settings: RSI period, oversold level, overbought level, trade direction (Long Only / Short Only / Both), and bar confirmation toggle are all configurable from the settings panel. Alerts are built in for both buy and sell signals.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.