Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.
What Is This Strategy?
The Pivot Rsi Reversion strategy is a mean-reversion trading system that combines pivot points (a classic support-and-resistance framework) with the Relative Strength Index, or RSI (a momentum oscillator that measures how overstretched recent price moves have become). Mean reversion is the idea that price, after stretching too far from a central value, often snaps back toward it. This Expert Advisor (EA) for MetaTrader 5 tries to identify those overstretched "pokes" into the edge of a price band and fade them — that is, trade against the short-term move in anticipation of a bounce back toward the middle.
Rather than using the traditional "previous-day" pivot calculation, the strategy builds a rolling pivot ladder. On every newly closed bar it looks back over a configurable window of completed bars, finds the highest high and lowest low, and recomputes a central pivot (P) along with two support lines (S1, S2) and two resistance lines (R1, R2). Because it only ever reads bars that have already closed, the calculation is non-repainting — the levels do not shift around after the fact, which makes the logic honest and reproducible in backtests.
This is best understood as a learning tool for studying how support/resistance and momentum filters can be combined into a single disciplined rule set. It is designed for range-bound or choppy market conditions, where price oscillates between bands rather than trending strongly in one direction. It suits traders who want to study confluence-based entries, structural stop placement, and reward-to-risk filtering — not those looking for a hands-off shortcut.
How It Works
The strategy evaluates its rules once per newly closed bar and holds at most one position at a time per magic number. Here is the full logic in plain English.
Building the pivot ladder (every closed bar):
- It scans the last
PivotLookbackclosed bars to find the highest high (H) and lowest low (L), and takes the close (C) of the most recent closed bar. - Central pivot: P = (H + L + C) / 3 — this acts as the "magnet" and the take-profit target.
- Fade lines: R1 = 2P − L and S1 = 2P − H — the levels the strategy fades from.
- Structural references: R2 = P + (H − L) and S2 = P − (H − L) — used to anchor the stop-loss.
Long (buy) entry — the strategy signals a long when all of these are true:
- The just-closed bar is bullish (its close is above its open).
- That bar's low dipped to or through S1 (support was tested).
- But the bar closed back above S1 (support held — the dip was rejected).
- RSI is oversold (below the
RsiOversoldthreshold), confirming momentum is stretched to the downside.
Short (sell) entry — the strategy signals a short when all of these are true:
- The just-closed bar is bearish (its close is below its open).
- That bar's high spiked to or through R1 (resistance was tested).
- But the bar closed back below R1 (resistance held — the spike was rejected).
- RSI is overbought (above the
RsiOverboughtthreshold), confirming momentum is stretched to the upside.
Stop-loss logic:
- For longs, the stop is placed below the lower of S2 or the signal bar's low, minus an ATR buffer (Average True Range, a volatility measure). The buffer is
AtrStopMult × ATR. - For shorts, the stop is placed above the higher of R2 or the signal bar's high, plus the same ATR buffer.
- Because the buffer scales with ATR, the stop automatically widens in volatile conditions and tightens in calm ones.
Take-profit logic:
- Both longs and shorts target the central pivot P — the mean the price is expected to revert toward.
Additional filters before any trade is placed:
- One position per magic — no stacking of trades; the ATR stop and pivot target manage the exit.
- Spread gate — if the current spread (in points) exceeds
MaxSpreadPoints, the setup is skipped. - Minimum reward:risk — the distance to the target divided by the distance to the stop must be at least
MinRewardRisk, otherwise the setup is discarded as not worth taking.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| PivotLookback | 20 | 10 | 60 | Number of closed bars used to build the rolling pivot ladder (highest high / lowest low window). |
| RsiPeriod | 14 | 7 | 28 | Lookback length for the RSI momentum oscillator. |
| RsiOversold | 35 | 15 | 45 | A long entry requires RSI to be below this level (momentum stretched down). |
| RsiOverbought | 65 | 55 | 85 | A short entry requires RSI to be above this level (momentum stretched up). |
| AtrPeriod | 14 | 7 | 28 | Lookback length for the ATR volatility measure used to size the stop buffer. |
| AtrStopMult | 1.00 | 0.20 | 3.00 | ATR multiple added beyond the structural stop level (S2/low or R2/high). |
| MinRewardRisk | 1.00 | 0.30 | 3.00 | Minimum acceptable reward:risk ratio (target distance ÷ stop distance) for a trade to be taken. |
| MaxSpreadPoints | 100 | 5 | 300 | Skip new entries when the current spread (in points) is wider than this. |
| Lots | 0.10 | 0.01 | 1.00 | Fixed trade volume in lots. |
| Magic | 7401 | 0 | 9,999,999 | Unique EA identifier so it manages only its own positions. |

Recommended Chart Settings
This strategy was designed around a liquid FX major such as EURUSD on the M15 (15-minute) timeframe. Liquid majors tend to have tight spreads, which helps the spread gate and keeps the cost of fading short-term moves manageable. The M15 timeframe offers a balance between signal frequency and noise.
That said, because every distance in the strategy scales with ATR and the rolling range, the rules are intended to be symbol- and volatility-agnostic and can be studied across other instruments and timeframes. Keep in mind that results will vary considerably across different market conditions — a setting that behaves one way in a quiet range may behave very differently in a strong trend or during a news-driven spike.
How to Install on MetaTrader 5
- Download the
.ex5file from the link below. - Copy it to your MT5
MQL5\Expertsfolder. - Restart MetaTrader 5 or refresh the Navigator panel.
- Drag the EA onto a chart matching the recommended symbol and timeframe.
- Configure the input parameters and enable Algo Trading.
What to Consider Before Using This EA
Strengths of this approach. The Pivot Rsi Reversion logic is built on confluence: it requires both a structural rejection at a pivot band and a stretched RSI reading before acting. This double filter is designed to keep the strategy out of the many false signals a naked pivot touch would produce in a trend. The non-repainting rolling pivots make it honest to backtest, the ATR-scaled stop adapts to volatility, and the explicit reward:risk filter discards setups where the target is too close to justify the risk.
Known limitations. Mean-reversion strategies share a structural weakness: they fade moves, which means they are, by design, trading against momentum. In a strong, sustained trend, support and resistance bands get broken repeatedly, and a fade strategy can take a series of losing trades as price runs away from the pivot. RSI thresholds can also stay "stretched" for long periods during powerful moves without reverting. The fixed Lots sizing does not adjust to account equity, and the single-position rule means missed opportunities while a trade is open.
Where it may underperform. Trending markets, breakout environments, high-impact news events, and instruments with wide or erratic spreads are all conditions where this style historically struggles. It is most at home in calmer, range-bound phases — and identifying those phases in advance is itself a challenge. Treat it as a framework to study, test, and understand rather than a finished solution.
Risk Management Tips
Sound risk management matters more than any single entry rule. Consider these general principles as part of your education:
- Position sizing: Risk only a small, fixed fraction of your account per trade — many educators suggest no more than 1–2%. Adjust the
Lotsparameter so the distance to your stop translates into that fraction, rather than leaving it at a default that may be too large for your account. - Use a demo account first: Test the strategy thoroughly on a demo or backtest before risking real capital, so you can observe how it behaves across different conditions.
- Understand drawdown: Every strategy experiences losing streaks. Know the maximum peak-to-trough decline you are willing to tolerate, and stop to reassess if it is breached.
- Mind costs and spread: Fading short moves means costs (spread, commission, slippage) eat into small targets. The spread gate helps, but be realistic about trading costs.
- Never over-leverage: Leverage amplifies both gains and losses. Keep it conservative, especially while learning.
Risk Warning
Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.
Downloads
- Expert Advisor: PivotRsiReversion.ex5 (2 downloads)
- Source Code: PivotRsiReversion.mq5 (1 downloads)
- Documentation: PivotRsiReversion.pdf (2 downloads)