Discussing the article: "The MQL5 Standard Library Explorer (Part 11): How to Build a Matrix-Based Market Structure Indicator in MQL5"

 

Check out the new article: The MQL5 Standard Library Explorer (Part 11): How to Build a Matrix-Based Market Structure Indicator in MQL5.

Learn to engineer an MQL5 indicator that converts trend, momentum, and volatility into a single raw score using a matrix.mqh (ALGLIB). The article covers a separate‑window oscillator to validate the core mathematics, then a main‑chart indicator that plots non‑repainting buy/sell arrows when the score crosses user‑defined thresholds. An optional long‑term EMA filter, a minimum‑bar cooldown, and built‑in alerts make the tool practical for live trading.

Compile both indicators in MetaEditor (F7). Attach SmartMarketStructureMatrixIndicator_Separate to a chart: you will see a separate window with a blue line and a silver histogram. This verifies the underlying market score. Then attach SmartMarketStructureMatrixIndicator_Main to the same chart. The blue line remains (you can hide it by turning off the "MarketScore" plot), and now green buy arrows and red sell arrows appear directly on the price bars when the threshold‑cross conditions are met. Additionally, when a new signal appears on the latest bar, a pop‑up alert displays the signal type, time, price and score – perfect for traders who cannot watch the screen constantly.

On the Volatility 75(1) Index, M15, with default settings (WindowSize=50, BuyThreshold=-10, SellThreshold=10, EMAPeriod=200), the indicator tends to produce signals after a sustained move has exhausted: a buy arrow often appears after a bullish streak collapses into a sharp sell‑off, and a sell arrow after a bearish streak reverses upwards. The EMA filter helps avoid counter‑trend arrows, and the MinBarsBetween parameter reduces noise. Because the indicator uses only past bars (closed prices) and does not rely on future data, it never repaints. Backtesting shows that while not every signal is a winner, the combination of the composite score and the crossing logic creates a useful edge, especially when combined with proper risk management.

Fig. 3. SmartMarketStructureMatrixIndicator_Main – buy and sell arrows on the main chart, with alerts on new signals.

Fig. 3. SmartMarketStructureMatrixIndicator_Main – buy and sell arrows on the main chart, with alerts on new signals.


Author: Clemence Benjamin