Skip to content
All library documents

Trading Indicator Divergence with Extremum Stops and Risk-Based Targets

Article MQL5 code base

Summary

This expert advisor opens trades when the DivergenceViewer indicator registers a configured class of divergence. It places the stop beyond the local price extremum reached during the divergence formation, with a configurable point offset. The take-profit distance is set as a configurable multiple of the entry-to-stop distance, tying the target to the trade’s initial risk.

The EA duplicates the indicator’s divergence settings and requires enough chart history to calculate its underlying indicator correctly. The document illustrates this requirement with a long lookback example for the William Blau indicator. It points readers to a separate article for fuller specifications and test results, but those results are not included here. No performance conclusions can be drawn from this excerpt, and outcomes depend on divergence settings, historical data, and execution conditions.

Key ideas

  • The EA trades when the indicator detects a configured class of divergence.
  • Stops are placed beyond the formation-period extremum with a configurable offset.
  • Take-profit distance is set as a multiple of the stop distance.
  • Sufficient chart history is required for accurate underlying indicator calculations.
  • The excerpt refers to separate testing but gives no performance results.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.