Strategy · Pine Script v5 · On the chart

Mean Reversion Trading Bot

by BenjaminLettner

This strategy executes mean-reversion trades by combining RSI momentum, Bollinger Bands volatility, dynamic ATR stops, and Exponential Moving Averages for trend filtering.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code229
Settings19inputs
LicenceNone stated
Last update8 months ago12 Feb 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

Mean Reversion Trading Bot seeks entry opportunities when price reaches extreme Bollinger Band boundaries alongside overbought or oversold RSI levels. Long and short trades can be selectively enabled, with optional volume moving average filtering. Risk management features include ATR-based stop loss and take profit multipliers. The strategy draws directly on the main price chart.

Details

Published by

BenjaminLettner on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI Lengthint14rsi_length
RSI Oversold Levelint30rsi_oversold
RSI Overbought Levelint70rsi_overbought
RSI Neutral Lowint45rsi_neutral_low
RSI Neutral Highint55rsi_neutral_high
Bollinger Bands Lengthint20bb_length
BB Standard Deviationfloat2.0bb_mult
Short EMAint20ema_short
Long EMAint100ema_long
ATR Lengthint14atr_length
ATR Stop Loss Multiplierfloat1.5atr_mult_sl
ATR Take Profit Multiplierfloat2.0atr_mult_tp
Show all 19 settings
SettingTypeDefaultVariable
Max Risk Per Trade (%)float2.0max_risk_per_trade
Max Drawdown (%)float20.0max_drawdown
Profit Target (%)float3.0profit_target_pct
Enable Long Tradesbooltrueenable_long
Enable Short Tradesbooltrueenable_short
Use Volume Filterbooltrueuse_volume_filter
Volume MA Lengthint20volume_ma_length
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

This mean-reversion strategy combines multi-timeframe exponential moving averages, Bollinger Bands, and the Relative Strength Index. It generates long and optional short trade signals when price interacts with the Bollinger Bands alongside RSI threshold confir

Strategy v5 Mean reversionMoving averages
Updated 2 months ago · None stated GitHub repository of MEMA + BB + RSI [Alorse]
7 stars

This strategy plots a simple moving average basis and upper and lower Bollinger bands on the price chart, with a fill between the bands. It also calculates RSI. It opens one long trade when RSI is above 25, price is at or below the lower band, and no position

Strategy v5 Volatility & bandsOscillators & momentum
Updated 4 years ago · GPL-3.0 GitHub repository of Bollinger Bands Strategy

Simpleton GROK

by eltonaguiar
4 stars

This strategy plots on the price chart and combines up to seven optional modules that vote for long or short conditions. The modules use a 20-period simple moving average, a five-period RSI, Bollinger Band squeezes, a simplified prior-bar break, stacked expone

Strategy v5 Oscillators & momentumMoving averages
Updated 2 days ago · None stated GitHub repository of Simpleton GROK

BB RSI Strategy

by infinityhao
3 stars

BB RSI Strategy combines Bollinger Bands, RSI, and multiple simple moving averages directly on the main price chart. It enters long positions when price drops below the lower Bollinger Band while RSI is below a set limit, and enters short positions when price

Strategy v4 Volatility & bandsOscillators & momentum Repaints
Updated 5 years ago · None stated GitHub repository of BB RSI Strategy
1 stars

Calculates a reversal confidence score combining Bollinger Band overextension, RSI exhaustion, and price distance from a exponential moving average. The strategy overlays VWAP, EMA, and Bollinger Bands directly on the price chart. Long signals trigger when pri

Strategy v5 Mean reversionOscillators & momentum
Updated 9 months ago · None stated GitHub repository of Reversal Confidence Strategy
1 stars

This strategy plots an anchored volume-weighted average price and two standard-deviation bands on the price chart. It buys dips below the inner band when a short RSI is oversold and an optional EMA trend filter agrees, and it can sell rallies above the inner b

Strategy v6 Mean reversionMoving averages
Updated 3 months ago · MIT GitHub repository of VWAP Reversion Bands [QuantForge]

More Mean reversion scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers