Discussing the article: "Building a Divergence System (Part VI): A Scoring Divergence Engine"

Check out the new article: Building a Divergence System (Part VI): A Scoring Divergence Engine.

A reusable MQL5 divergence engine that stores all confirmed pivots, selects clean pivot pairs, and measures price extension in ATR, oscillator disagreement, and bar spacing into a 0–100 score. It logs named rejection reasons for filtered pairs and exposes per‑bar queries. Integration is reduced to four steps, and the score can drive an adaptive trailing system that scales its SAR step by divergence strength.

The previous part ended on what its trailing header could not do. It could react to an opposing divergence and limit how old that divergence was allowed to be, but it could not tell a large divergence from a small one. Every divergence the engine found counted the same. This was true whether price barely made a new low or broke well below the old one, and whether the oscillator disagreed by a fraction of a point or by a wide margin. This part builds the engine that measures those things. It measures size and nothing else. Whether a larger divergence is more often followed by a reversal is a separate question, and this part does not test it.

The first part described the problem in its limitations. In a sideways market, price and the oscillator can form many small pivots that meet the divergence conditions without any reversal, so the indicator prints an arrow on each one. The same article advised that a bullish arrow near the oversold level is stronger than one near zero. The engine has no way to act on that advice. Its output is a divergence type and a bar count, so a large divergence and a small one produce the same result. The engine also compares each new pivot with a single remembered pivot. The Adaptive SuperTrend indicator shows this in its state buffers, where LastPivLowPriceBuffer[] stores the most recent pivot low price. When a shallow pivot forms between two meaningful lows, it replaces the older low in memory, and the comparison that mattered is never made.


Author: Solomon Anietie Sunday