Strategy · Pine Script v6 · On the chart

Regime-Gated Dip Reversion

by jayadevrana

This long-only strategy buys short-term oversold dips only inside a strong uptrend: price above a rising 200-period SMA and within a set percentage of its one-year high.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code119
Settings17inputs
LicenceCustom licence
Last update2 months ago7 Aug 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

Entry needs a two-period RSI below a threshold, then an up-close, and volatility below an ATR percentile limit. It exits when price closes above a short SMA, an ATR stop is hit, the regime fails or a maximum holding time ends. It holds one position, sized as a share of equity.

Details

Published by

jayadevrana on GitHub

Draws

On the price chart

Markets

Stocks

Timeframes

H4 and above

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.

Topics

indicatormarket-structurepine-scriptpinescript-v6supply-demandtradingview

Settings

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

SettingTypeDefaultVariable
Bull-regime SMA lengthint200regimeLen
Require rising regime SMAbooltrueuseSlope
Regime slope lookbackint20slopeLen
Uptrend high lookback (bars)int252hiLen
Only buy within % of that highfloat15hiTolPct
RSI lengthint2rsiLen
Buy when RSI belowfloat10rsiBuy
Require up-close reversal confirmationbooltrueuseReversal
Only buy in calm volatilitybooltrueuseCalm
ATR percentile lookbackint100volLen
Skip entries above ATR percentilefloat70maxVolPct
Reversion exit SMA lengthint5exitMaLen
Show all 17 settings
SettingTypeDefaultVariable
Use protective ATR stopbooltrueuseAtrStop
ATR lengthint14atrLen
ATR stop multiplefloat2.5atrStopMult
Max bars in tradeint15maxHold
Show regime / exit moving averagesbooltrueshowMas
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 strategy calculates Bollinger Bands and Aroon oscillator values to identify mean-reversion opportunities. It enters a long position using full equity when the closing price crosses below the lower Bollinger Band while Aroon Up remains above a user-specifi

Strategy v5 Mean reversionVolatility & bands
Updated 2 months ago · None stated GitHub repository of Bollinger bands + Aroon [Alorse]
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy

8 Day Run

by hasnocool
106 stars

Inspired by Linda Raschke's strategy for T-note futures, this script identifies extended trends where price remains on one side of a 5-period SMA for more than eight consecutive bars. It enters long on the first pullback below the SMA following an eight-bar bu

Strategy v4 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 8 Day Run

Bollinger Bands Strategy

by cklose2000
105 stars

This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po

Strategy v5 Volatility & bandsMoving averages
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Strategy
53 stars

This strategy identifies long entry opportunities based on short-term price pullbacks below a major trend filter. It enters long when three consecutive lower closes occur below the 200-period simple moving average, followed by the current bar closing back abov

Strategy v6 TrendMoving averages
Updated 2 months ago · MPL-2.0 GitHub repository of Ivan Scherman Pattern - TP/SL

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