Skip to content

Mean reversion

Mean Reversion Trading Strategy: Rules, Stops and Alerts

A mean reversion trading strategy enters when price has stretched a measured distance from a reference level, such as a moving average, and exits as price moves back toward it. Common triggers are a close outside a Bollinger Band, a z-score beyond a threshold or an RSI extreme. The hard part is the stop: a stretch can keep extending, and the rule must say when the bet is wrong.

Illustrative cover for mean reversion rules, showing an abstract price path dipping below a lower band and returning toward a middle line, with the official PineConnector logo.
Mean reversion rules fade a measured stretch and exit near the mean. Illustrative.

This page belongs to PineConnector's trading strategy library. Mean reversion is the opposite bet to trend following: one expects a move to fade, the other expects it to continue. Every rule below is an illustrative example to test, not a recommendation.

Mean reversion strategy at a glance

Scroll horizontally to read every column.

Item Mean reversion as a rule
Behaviour it expects A stretch away from a reference level is followed by a move back toward it.
Reference level An N-bar moving average, a session VWAP, or another stated mean.
Common triggers Close below the lower Bollinger Band, z-score below −k, or RSI below a threshold.
Common exits Close at or above the mean, a time limit in bars, or a stop further out.
Typical shape Frequent small gains and occasional large losses, because the target is near and the stop is far.
What breaks it A persistent trend, where price keeps closing outside the band.

How do you measure distance from the mean?

Every mean reversion rule needs a reference level, a measure of normal distance and a threshold. Bollinger Bands supply all three. TradingView's help page gives the standard calculation: a 20-day simple moving average as the middle band, with upper and lower bands two standard deviations above and below it.[1]

z = (close − SMA of N bars) ÷ standard deviation of N bars

With k standard deviations, the lower band is SMA − k × σ, so “close below the lower band” is the same test as z < −k. Writing the rule as a z-score makes the threshold explicit and lets you compare instruments with different price levels. Pine Script v6 provides ta.sma, ta.stdev and ta.bb for these values.[12] The Bollinger Bands rules page covers band width and %b.

John Bollinger created the bands. He warns against reading a band touch as a signal on its own. In his words, "Tags of the bands are just that, tags not signals."[2] His rules call 20 periods and two standard deviations defaults, "just that, defaults".[2] A mean reversion rule adds what the band leaves out: a trigger, an exit and a stop.

RSI is the other common trigger. J. Welles Wilder introduced it in 1978 and considered readings above 70 overbought and below 30 oversold.[3] An oversold reading describes recent gains and losses. It does not say a reversal is due, and RSI can stay below 30 through a long decline. The RSI rules page covers its formula and crossing tests.

Worked example: a two-standard-deviation band entry

Illustrative values, not a recommendation. On a closed bar, the 20-bar SMA is 1.10000 and the 20-bar standard deviation is 0.00250. One PineConnector pip on a five-decimal quote is 0.00010.[7]

Step Calculation Result
Lower band, k = 2 1.10000 − 2 × 0.00250 1.09500
Entry test Close 1.09400: z = (1.09400 − 1.10000) ÷ 0.00250 z = −2.4, below −2, so the long condition is true
Stop at z = −4 of the entry bar 1.10000 − 4 × 0.00250 = 1.09000 Risk = 0.00400, or 40 pips = 1R
Target at entry Middle band 1.10000 − 1.09400 60 pips = 1.5R
Exit later The SMA has fallen to 1.09700 when a close reaches it 1.09700 − 1.09400 = 30 pips = +0.75R before costs

The target moved. The middle band is an average of recent closes, so it drifts toward price while the trade is open. A rule that exits “at the mean” gets less than the distance seen at entry whenever the mean falls to meet price. A fixed take-profit price sent at entry does not follow the mean; the two are different rules.

Illustrative mean reversion diagram: a close below the lower Bollinger Band at z of minus 2.4 opens a long, the target is the moving middle band, the stop is at z of minus 4, and a trend that walks the band is the failure case.
Illustrative values, not recommended settings. The mean moves while the trade is open, so the target shrinks; a persistent trend reaches the stop instead.

Why does mean reversion need a high win rate?

The shape comes from the exit geometry, not from a measured result. The target sits near, at the mean. The stop has to sit far enough away to survive normal noise, often beyond the entry trigger. That combination makes the average win smaller than the average loss for many rule sets.

Using the house break-even formula with illustrative inputs, an average win of 0.5R against an average loss of 1R breaks even before costs at:

Break-even win rate = AL / (AW + AL) = 1 / (0.5 + 1) = 66.7%

PineConnector's Analytics guide gives the same before-costs relationship.[4] With a cost of 0.05R per trade, the formula becomes (AL + c) / (AW + AL) = 1.05 / 1.5 = 70%. These numbers describe what such a rule would need. They are not results of any strategy, and a rule with a different stop has a different requirement. The payoff ratio guide explains the average-win to average-loss ratio.

A long run of small gains can therefore sit next to a single loss that erases many of them. Judge a mean reversion test by its worst losses and drawdown, not by how often it wins.

Why are stops the hard part of mean reversion?

A mean reversion entry buys weakness. If the stop sits close to the entry, ordinary noise that the rule expects to reverse will hit it. If the stop sits far away, each stopped trade costs many average wins. With no stop at all, a trend can carry losses far beyond anything the backtest showed.

Bollinger's rules name the failure case. His rule 7 reads: "In trending markets price can, and does, walk up the upper Bollinger Band and down the lower Bollinger Band."[2] Rule 8 goes further: closes outside the bands "are initially continuation signals, not reversal signals".[2] A mean reversion rule is taking the other side of that reading, so it needs an explicit answer for when the band walk continues.

  • Price stop: a level beyond the trigger, such as z = −4 or a recent swing low. Say whether the level is fixed at entry or recalculated.
  • Time stop: close after a set number of bars if price has not reached the mean. The idea was a quick return; a slow one is a different market.
  • Regime filter: skip entries when a trend measure is strong, for example using the ADX rules page. A filter is another parameter, so it adds overfitting risk.

Adding to a losing mean reversion position, averaging down, removes the fixed loss per trade. The martingale and grid risk page shows how that path concentrates losses.

How does a mean reversion rule map to alerts and MT5 orders?

A TradingView strategy calculates once per closed bar by default.[5] Alerts trigger only on realtime bars, and an alert set to once per bar close fires when that bar closes.[6] A close-based band rule should use that setting, or it may send an entry for a bar that later closes back inside the band.

Rule element TradingView side MT5 side
Entry Close below the lower band, on the bar close A market buy request, or a buy limit at a stated level
Stop z = −4 of the entry bar A broker-side stop only if the message includes one
Exit at the mean A close at or above the moving middle band A close message sent by that alert
Time stop Bars since entry reach the limit A close message sent by that alert

The exit at a moving mean cannot sit at the broker as a fixed take-profit, because its level changes every bar. It has to arrive as a close message. The protective stop is different: PineConnector's converter guide states the integration does not place a script's simulated stops as protective broker orders.[13] Send the stop in the entry message if you want it held at the broker.

Verify on a demo account first. PineConnector's demo testing guide says a successful demo order verifies the tested setup, not that the strategy will be profitable.[9] Choose your own symbol, size and rules. Illustrative messages for the TradingView alert's Message field, not an instruction to trade:

LicenseID,buy,EURUSD,vol_lots=0.01,sl_pips=40,comment=MR-A
LicenseID,closelong,EURUSD,comment=MR-A

The first requests a 0.01-lot buy with a stop 40 PineConnector pips from entry, labelled MR-A. The second, sent by the exit or time-stop alert, requests closing only EURUSD buys carrying that comment.[14] For a limit entry at the band instead, the pending commands reference lists buylimit for buying below market; stop and target distances on a pending order use the pending entry.[8]

The broker fills at its own Ask or Bid. MetaQuotes notes that buying executes at Ask and selling at Bid.[10] TradingView and MetaTrader can also show different prices, so a band on one chart may not match the broker's.[11]

What else goes wrong with mean reversion rules?

  • Counting touches as edges. A band touch or an RSI reading is a measurement. The rule's result depends on exits and stops, which the indicator does not supply.
  • Costs on small targets. A target of a fraction of R leaves little room for spread and commission. The transaction costs guide shows how to count them.
  • Tuning the threshold. Trying many values of N, k and the stop on one history finds the best past fit. TradingView warns an overfit strategy "often fails to perform well on new, unseen data".[5]
  • Short samples. Rare large losses may not appear in a short test at all. The backtest sample size guide explains why a small trade count says little.

Frequently asked questions

What are mean reversion strategy rules?

Mean reversion strategy rules define a reference level, a distance that counts as stretched, an entry trigger, an exit near the reference level and a stop for when the stretch keeps going. An illustrative set buys a close below the lower Bollinger Band and exits at the middle band. The values are choices to test, not recommendations.

How does RSI mean reversion work?

RSI mean reversion treats an RSI reading below a threshold, such as Wilder's 30, as stretched and buys on the expectation of a rebound, exiting when RSI or price recovers. RSI can stay below 30 through a long decline, so the rule needs a price or time stop. The same reading supports a momentum rule read the opposite way.

Is Bollinger Band mean reversion a buy signal at the lower band?

A lower Bollinger Band touch is not a buy signal on its own. John Bollinger states that tags of the bands are "tags not signals", and that price can walk down the lower band in a trend. A Bollinger Band mean reversion rule adds a trigger, an exit at a stated level and a stop, then tests them together.

Why do mean reversion strategies have large losses?

Mean reversion strategies can have large losses because the target sits near the mean while the stop sits further away, so one stopped trade can cost several average wins. In a persistent trend, price keeps moving away from the mean. Without a stop, a single trend can produce a loss far larger than any seen in testing.

Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account and no code was compiled.

Related reading

Sources

  1. TradingView Help Center – Bollinger Bands (BB), accessed 25 September 2026.
  2. John Bollinger – Bollinger Bands Rules, accessed 25 September 2026.
  3. TradingView Help Center – Relative Strength Index (RSI), accessed 25 September 2026.
  4. PineConnector – Analytics: win rate, reward-to-risk and expectancy, accessed 25 September 2026.
  5. TradingView – Pine Script User Manual: Strategies, accessed 25 September 2026.
  6. TradingView – Pine Script User Manual: Alerts, accessed 25 September 2026.
  7. PineConnector – Syntax: message structure and PineConnector pip, accessed 25 September 2026.
  8. PineConnector – Syntax: pending commands, accessed 25 September 2026.
  9. PineConnector – Demo testing: test an active setup on a broker demo account, accessed 25 September 2026.
  10. MetaQuotes – MetaTrader 5 Help: orders, deals and positions, accessed 25 September 2026.
  11. PineConnector – Frequently asked questions: price differences, accessed 25 September 2026.
  12. TradingView – Pine Script v6 reference: ta.sma, ta.stdev, ta.bb and ta.rsi, accessed 25 September 2026.
  13. PineConnector – Pine Script converter: supported behaviour, accessed 25 September 2026.
  14. PineConnector – Keep strategies separate: closing with comments, accessed 25 September 2026.

PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.


Leave a comment

Back To PiCo Blog

Ready when your strategy is

You bring the strategy.We bring the infrastructure.

Connect TradingView to MetaTrader, choose where MT5 runs and put the full PineConnector workflow through its paces from your first month.

Strategy and trading decisions remain yours. The MT5 environment can be ours.

PineConnector Edge

Run the full PineConnector workflow.

$59/mo at launch

Core plan · 1 connection · 1 hosted MT5 environment

Try Core for $7

7 days of Core for $7, then $59/month at the launch price unless you cancel.