Regular Hidden Divergence Detector
- Indicatori
-
Kazuma Uezono
MQL5 / MQL4 / Pine Script v6 developer and active trader.
Seller on the MQL5 Market (indicators for MT4/MT5).
Services:
- TradingView Pine Script to MT5/MT4 conversion (bar-by-bar matching, with tester report)
- MT4 to MT5 migration - Versione: 1.0
- Attivazioni: 5
Divergence Detector finds regular and hidden divergences between price swings and one oscillator of your choice (RSI, MACD histogram, Stochastic %K, OBV, CCI or Momentum). It draws them as lines on the price chart and in the indicator window, and a small table shows the latest divergence on four other timeframes. It is a display tool: it gives no buy / sell signals and does not place orders.
HOW A DIVERGENCE IS FOUND
- Swings are price pivots: a high that is higher than the 5 bars on its left and not lower than the 5 bars on its right (lows the other way). Both counts can be changed.
- A new swing is compared with earlier swings on the same side that are 5 to 60 bars back (inputs).
- Regular bearish: higher high in price, lower high in the oscillator. Regular bullish: lower low in price, higher low in the oscillator.
- Hidden bearish: lower high in price, higher high in the oscillator. Hidden bullish: higher low in price, lower low in the oscillator.
- The oscillator difference must be at least 5% of the oscillator's range between the two swings (input, 0-100%).
- Line-crossing check (Off / Price only / Indicator only / Price and indicator, default Price only): no bar between the two swings may go beyond the straight line that joins them.
- For each type, only the most recent earlier swing that meets all conditions is used, so one swing gives at most one line per type.
- Regular divergences are on and hidden divergences are off by default. Regular lines are solid, hidden lines are dashed.
WHEN THE LINES APPEAR (please read)
- Only closed bars are used. A swing is confirmed when its right-side bars have closed, so every line appears 5 bars (the right-side count) after the second swing. This delay is part of the method.
- Once a line has been drawn, it is not moved or removed while the indicator is running. Before release, the lines drawn bar by bar were compared with an independent recalculation from the same price data and with the chart after more bars had closed; no differences were found in these tests.
- The analysis covers the last 2000 closed bars at start-up (input 200-20000) and its start stays fixed. If older history is downloaded later, it is used only after the indicator restarts (for example after changing a setting or the timeframe).
OSCILLATORS (one per copy)
- RSI (14), MACD histogram (12, 26, 9), Stochastic %K (14, 3, 3), OBV (tick volume), CCI (14), Momentum (14). All periods can be changed.
- MACD histogram here means MACD line minus signal line. This is not the same picture as the standard MetaTrader 4 MACD, which shows the MACD line as bars and the signal as a line.
- OBV: the absolute OBV value depends on where the loaded history starts, but divergences use only differences between the two swings, so the lines are the same. Tick volume comes from your broker's data, so OBV results can differ between brokers.
- To watch two oscillators, add the indicator twice (up to 8 copies on one chart). Labels of the second and later copies are moved slightly outward so they do not overlap.
HOW OFTEN LINES APPEAR (for reference only)
With the default settings (RSI 14, regular only, 5 bars on each side), past MetaTrader 5 charts (same calculation as this MT4 version) showed roughly one divergence per 58 bars on EURUSD H1, one per 64 bars on USDJPY M15 and one per 60 bars on GOLD H4. This is only a count of how often lines were drawn. It says nothing about what price did afterwards, and it differs by symbol, period and settings.
TIMEFRAME TABLE
- Shown in the indicator window for M15, H1, H4 and D1 (each can be changed): the type of the latest divergence and how many bars ago its second swing was, for example "Bull 7 bars".
- "none" means no divergence was found in the analysed bars. "—" means the data is still loading or there is not enough history.
- Position (four corners of the indicator window) and text size can be changed.
ALERTS
- Off by default. When on: pop-up, sound and / or push notification.
- Only divergences newly confirmed on the chart timeframe after the indicator starts are alerted (not past bars, not the table timeframes).
DISPLAY
- Tooltip on each line: type, oscillator values at the two swings, swing times and the bar on which it was confirmed.
- Labels, table, tooltips and alerts in English or Japanese, chosen automatically from the terminal language (can also be set by hand).
- Lines on the price chart and in the indicator window, labels, colours and line width can be switched or changed.
IMPORTANT
- Not a buy / sell signal, not a trade, take-profit or stop-loss level, and not a probability. A divergence only shows that price and the oscillator moved differently between two swings.
- In a strong trend, divergences against the trend can appear several times in a row while the trend continues. Because of the confirmation delay, price may already have moved by the time a line appears.
- It does not promise any win rate or profit, and past charts do not guarantee future results. Trade decisions are your own responsibility.
- Bar boundaries depend on the broker's server time, so lines can differ between brokers for the same symbol.
- Objects whose names start with "DVD<number>_" are treated as this indicator's drawings and are cleaned up. Do not use such names for your own objects.
- Push notifications need the terminal's notification settings.
OTHER
- MetaTrader 4 only (the MT5 version is a separate product). Works on any symbol and timeframe.
- Works with templates and after a terminal restart.
- No DLLs, no external files, no internet access.
- A PDF user guide (English or Japanese) is available: send a message through MQL5 after purchase and it will be sent to you.
- Support through MQL5 messages, reply within 3 business days: installation, settings and bug reports only. Questions about market views, trade decisions or how to read a result cannot be answered.
