Discussing the article: "Building a Divergence System (Part IV): Creating a Reusable Divergence Engine for MQL5"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Building a Divergence System (Part IV): Creating a Reusable Divergence Engine for MQL5.
The article extracts the series' divergence logic into DivergenceEngine.mqh, a reusable header for MQL5 indicators and Expert Advisors. It details the struct-based design, oscillator options (MPO4 or RSI), pivot and state handling, and the minimal access API. A Parabolic SAR EA demonstrates integration by adapting the acceleration factor from the detected divergence, providing a clear pattern you can reuse without duplicating code.
That is a reasonable approach for a single, self-contained system, but it comes with a cost: none of these components exist independently. They are embedded in the SuperTrend loop, sized around its lookback, and initialized with SuperTrend-specific boundary values. If another indicator or an unrelated EA needs the same divergence behavior, there is no clean interface to provide it. The practical alternative is to copy the relevant code into the new project and adjust it until it compiles. That kind of "reuse" becomes a maintenance problem when one copy gets a bug fix and the other doesn't. The illustration below visually simplifies this:
Oscillator, pivot detection, divergence detection, and state memory live inside a single implementation and can only be used there.
Author: Solomon Anietie Sunday