Momentum Divergence Scanner
- Indicators
- Version: 1.0
- Activations: 5
# Momentum Divergence Scanner - Divergences without repaint
*Category: Momentum | Difficulty: intermediate | Window: chart window (overlaid on price) | Markets: Universal (Forex, indices, commodities, crypto, stocks) | Suggested timeframes: M15, M30, H1, H4, D1*
## Short description
> Flags price to momentum divergences using confirmed swings only. The arrow appears on confirmation and is never withdrawn, unlike almost every other divergence indicator.
### Overview
Almost every divergence indicator in circulation shares the same flaw: it draws the signal on the freshly formed high or low and then deletes it if the market moves past that point. On historical charts the result looks impeccable, because every wrong signal has been removed, but in real time the signal appears and vanishes, making any serious verification and any automation impossible. Momentum Divergence Scanner takes the opposite route. It locates swings with the classic fractal definition and only considers them once confirmed by InpWing bars to their right. The arrow is printed on the bar where the divergence becomes objectively verifiable, so it arrives later, but it is never withdrawn.
### How the calculation works
1. An internal momentum is computed as the close to close change over InpMomPeriod bars, normalised in ATR units.
2. Price swings are located with the fractal definition: a bar whose extreme exceeds that of InpWing bars on each side.
3. For every confirmed swing the price and the momentum value on that bar are stored, together with those of the previous swing.
4. A bullish divergence requires a new price low lower than the previous one and a momentum higher by at least InpMinMomGap.
5. The arrow is placed on the confirmation bar, at a distance of InpArrowShift ATR from price, so it stays readable at any zoom level.
6. The entire swing state is kept in calculation buffers, so recalculating a bar never alters signals already printed.
### How to use it
- Treat the arrow as a weakening warning, not an entry order: divergence says the thrust has reduced, not that price will reverse.
- Look for confirmation at a level: a divergence forming against a known support or resistance is worth far more than an isolated one.
- Raise InpWing for fewer signals on more significant swings, accepting a longer confirmation delay.
- Raise InpMinMomGap to exclude marginal divergences, where the momentum difference is negligible and probably random.
- Always review the history before trading: being repaint free, past signals are exactly those that would have been seen in real time.
### Who it is for and on which timeframes
It targets traders who want to use divergences honestly, verifying their actual historical behaviour instead of admiring a chart cleaned up after the fact. It is also the only version usable by anyone wanting to automate the logic in an Expert Advisor, because a vanishing signal cannot be programmed. It works from M15 to D1. Anyone seeking the most timely possible signal will be disappointed by the confirmation delay: it is a deliberate and unavoidable trade-off.
### Practical example of reading a signal
On XAUUSD H1 price digs a low at 2318, bounces, then digs a new low at 2311. The second low is lower, but normalised momentum on that bar reads -0.9 against -1.6 on the first: the decline was deeper yet far less energetic. Three bars after the second low, once the confirmation bars are complete, the green arrow appears below price. The trader does not buy immediately: they wait for price to exceed the intermediate high between the two lows, which is the structural confirmation. The stop goes below 2311. The arrow stays on the chart in later sessions too, regardless of the outcome.
## Input parameters
| Parameter | Default | Description |
|---|---|---|
| `InpWing` | 3 | Confirmation bars required on each side of a swing. It determines both selectivity and the delay before the arrow appears. |
| `InpMomPeriod` | 14 | Horizon of the internal momentum compared with price. Short horizons produce more divergences but less meaningful ones. |
| `InpAtrPeriod` | 30 | ATR period used both to normalise momentum and to place the arrows at a constant distance from price. |
| `InpMinMomGap` | 0.15 | Minimum momentum difference between the two swings for the divergence to be accepted. Raising it removes marginal signals. |
| `InpArrowShift` | 0.60 | Distance of the arrows from the bar high or low, in ATR. Purely cosmetic, it does not affect signals. |
## Advantages / strengths
- No repaint, a nearly unique feature in this family of indicators and directly verifiable on historical data.
- Past signals correspond exactly to those that would have been seen in real time, so visual backtesting is trustworthy.
- The minimum momentum difference filter removes most random divergences.
- Usable inside an Expert Advisor, which is impossible with an indicator that withdraws its own signals.
## Limitations and warnings
- The signal arrives InpWing bars after the swing: part of the move has already happened when the arrow appears.
- Divergences work poorly in very strong trends, where they can repeat many times before price actually gives way.
- It only compares the last two swings of the same kind: it does not recognise extended divergences over three or more points.
- The number of signals depends heavily on InpWing: low values produce too many, high values almost none.
**No repaint:** values printed on a closed bar are never modified afterwards. The arrow appears on the confirmation bar, that is InpWing bars after the swing that generated it, and from then on it is never moved or removed. The signal is therefore later than that of repainting indicators, but it is verifiable on historical data.
**Disclaimer.** This product is a technical analysis tool, not an automated trading system, and it offers no profit guarantee whatsoever. Financial markets carry the risk of total loss of the invested capital. Past performance is not indicative of future results. Every signal must be confirmed with your own analysis, a money management plan and prior testing on a demo account. The author is not responsible for trading decisions taken on the basis of this indicator.
## Suggested tags / keywords for MQL5
`divergence`, `momentum`, `no repaint`, `fractal`, `swing`, `reversal`, `price action`, `signal`
