Non-Repainting Smart Money Concepts in MQL5

Non-Repainting Smart Money Concepts in MQL5

19 September 2026, 17:12
Jose Rodrgues Chaves
0
28

Why I Built a Non-Repainting SMC Indicator — And What I Learned Along the Way

A personal note on indicator design, Smart Money Concepts, and the discipline of not lying to yourself on the chart.

The Problem That Started It All

A few years ago, I was trading an SMC setup on Gold. A clean bullish CHoCH printed on my chart. I entered long. The candle closed. The label vanished.

I sat there staring at the screen, wondering if I had imagined it. I hadn't. The indicator had simply evaluated the forming bar — the one that was still moving — and when that bar closed differently than it looked mid-formation, the signal evaporated. What I had traded was never a real signal. It was a guess that looked like one.

That day I decided to build my own SMC indicator. Not because there weren't enough of them on the Market — there are plenty. But because almost every one I tried repainted, and the few that didn't were missing half the features I needed.

This blog is the story of what I built, what I learned about how SMC indicators should work, and a few design principles that any trader can use to evaluate tools they are considering.


What "Repainting" Actually Means

Most traders use the word loosely. Here's a more precise taxonomy I developed while working on this project:

  1. Bar-close repaint — the indicator reads the currently forming bar, and the signal changes when that bar closes. This is the most common and the most damaging.
  2. Index-shift repaint — the indicator caches bar indices instead of bar times. When MT5 reaches its history limit and drops the oldest bar, every index shifts by one, and stale signals appear on the wrong bars.
  3. Alert repaint — the indicator fires an alert mid-bar, then reverses it when the bar closes. You get a notification for a signal that never existed.

The interesting thing is that fixing (1) is easy — just skip the forming bar. Fixing (2) is subtle — you have to make every state variable time-keyed, not index-keyed. And fixing (3) requires discipline in the alert path.

An indicator that fixes only (1) still repaints in two other ways. Most tools never address (2) at all.


Design Principle 1: Pivots Must Be Symmetric

A swing high is not a swing high until the bars on both sides are lower. This sounds obvious, but it's the single most violated rule in SMC indicator design.

When I write pivot detection, I use this pattern:

void DetectPivots(const int i, const int len,
                  const double &high[], const double &low[],
                  const datetime &time[], const bool internal)
{
   if(i < len * 2)
      return;

   int lb = i - len; // lookback bar

   //--- Pivot High check
   bool isHigh = true;
   for(int j = 1; j <= len; j++)
   {
      if(high[lb - j] > high[lb] || high[lb + j] > high[lb])
      {
         isHigh = false;
         break;
      }
   }
   // ... (same for pivot low)
}

The line if(i < len * 2) return; is the guarantee. We cannot even begin scanning until we have len bars on each side of the candidate. The function is called with the current bar index i , and the candidate pivot is always at i - len . The right-side bars are already closed.

Any indicator that draws a pivot before this condition is met is guessing.


Design Principle 2: Structure Breaks Require a Close

A wick above a pivot high is a liquidity sweep, not a Break of Structure. The distinction matters — one is a trap, the other is a signal. Yet a surprising number of indicators check high[i] > pivot instead of close[i] > pivot .

Here's how I handle it:

if(highLevel > 0 && close[i] > highLevel && !highCrossed && extraBull)
{
   string tag = (curBias == BULLISH) ? "BOS" : "CHoCH";
   // ...
}

Three things to notice:

  • close[i] — not high[i] . The break must be a closing break.
  • highCrossed — once a pivot is broken, it never fires again, so no duplicate signals.
  • curBias — the label depends on the prior trend. Bullish break while bullish = BOS. Bullish break while bearish = CHoCH.

That last point is what separates a professional SMC engine from a toy. The difference between BOS and CHoCH is context, not price action.


Design Principle 3: Two Structure Engines, Not One

A common mistake is to run a single pivot length and call it "market structure." But markets have structure at multiple scales at once. A 50-bar swing high and a 7-bar internal high are both meaningful — they just serve different purposes.

Engine Default Length Purpose
Swing 50 bars Major trend direction, HTF bias
Internal 7 bars Entry timing, short-term shifts

Each engine has its own pivot pair, its own bias variable, and its own crossed flags. They never interfere with each other. A trader can use the swing structure for direction and the internal structure for entries.


What I Built

Over several months, I built Elohim FX – SNR Detection SMC Trendline Pro — a non-repainting SMC indicator that includes:

Market Structure

  • Swing and Internal BOS / CHoCH detection
  • HH / HL / LH / LL swing point labels
  • Optional confluence filter (only genuine bullish/bearish close bars confirm breaks)

Liquidity & Sweeps

  • MSS sweep engine — first-touch HL/LH with hidden CHoCH → BOS model
  • Protected Level tracking with optional Liquidity Zone lines

Order Blocks & Imbalance

  • Internal and Swing Order Blocks with independent counts
  • Close-based or high/low-based mitigation
  • Fair Value Gaps on the current OR any higher timeframe

Support & Resistance

  • Premium / Discount zones with Buy Power / Sell Power counters
  • Strong / Weak High/Low labels
  • Previous Day / Week / Month high and low lines
  • ZigZag SNR engine with open/closed level styling
  • Auto-drawn accurate trendlines from confirmed pivot anchors

Range Detector Boxes

  • Pine-style volatility range boxes using Wilder's ATR
  • Confirmed breakout coloring (up / down / active)
  • Timer-based live refresh — keeps advancing even on sparse-tick symbols

Multi-Timeframe Dashboard

  • Current timeframe bias (Swing + Internal + Last Signal)
  • Configurable ITF section (default H1)
  • Configurable HTF section (default H4)

Alerts

  • Popup, Sound, Push notification, Email
  • All alerts fire once per closed bar

Every detection pipeline in the indicator runs on closed bars only. The only exception is an optional Live ZigZag feature — clearly labeled, off by default.

SNR Detection SMC Trendline Pro


What I Learned

  1. Non-repainting is a discipline, not a feature. You cannot add it at the end. It has to be designed in from the first line of code.
  2. Most "SMC indicators" are pivot detectors with marketing. A true SMC engine needs context — prior bias, prior pivots, prior structure. Without context, BOS and CHoCH are indistinguishable.
  3. Traders underestimate bar-time vs bar-index. Half the repainting complaints I see on forums trace back to index-based caching. Time-based caching fixes them silently.
  4. The best indicator is the one you trust. Traders will forgive a tool that misses signals. They will never forgive a tool that lies to them.

A Note on What This Blog Is

This is not investment advice. It is not a signal service. It is a personal record of what I built, why I built it, and what I learned while building it. If you find any of these design principles useful — even if you never try my indicator — then this post has done its job.

The indicator is available on the MQL5 Market if you want to see the principles in action. The link is in my profile.

Trade safely.

— Jose Rodrigues Chaves


About the author: Independent MQL5 developer. Interested in non-repainting indicator design and Smart Money Concepts. All opinions are my own.