Non Repaint Spike Detector Indicator: Body And Range

Written by Dominic Walsh · Published · Last updated

The non repaint spike detector indicator asks two questions of the same bar. Was the body larger than `RangeMult` times ATR? And was the whole high to low range larger than `HLMult` times ATR? A bar has to pass both, which rules out a long wick with a small body.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 4: Spike Up, Spike Down, Range Hi, Range Lo
Alerts popup, push notification, email, sound
Inputs 11

What the Non repaint spike detector Indicator draws on the chart

Spike Up places a lime arrow under a bullish spike bar.

Spike Down places a red arrow above a bearish one.

Range Hi and Range Lo are the two dodger blue lines showing the spike threshold.

Arrow distance takes `ArrowOffsetATR` `0.6` of an ATR, so it scales with volatility.

  • Spike Up: arrow, lime, width 2, arrow code 233
  • Spike Down: arrow, red, width 2, arrow code 234
  • Range Hi: line, dodger blue, width 1
  • Range Lo: line, dodger blue, width 1
Non repaint spike detector indicator on EURUSD H1 with spike bars and threshold lines
Non repaint spike detector indicator on EURUSD H1 with spike bars and threshold lines

How the Non repaint spike detector Indicator calculates its values

One forward pass for ATR

The code seeds ATR with a simple mean and then applies Wilder smoothing forward through history. Doing it once keeps the whole calculation linear, rather than recomputing an average at every bar.

Two size tests

body takes the absolute close minus open. hl takes high minus low. spike needs body above ATR times `RangeMult` `1.6` and hl above ATR times `HLMult` `1.9`. Direction then comes from the sign of close minus open.

Drawing the threshold

RangeHi and RangeLo sit half of `HLMult` times ATR either side of the bar midpoint. Together they show how large a bar would have to be to qualify. That makes a near miss visible rather than invisible.

How to read the signals

A spike bar is unusual by construction, so marks stay rare.

The two blue lines show the bar you would need on this bar.

Requiring both tests rules out a long wick with a tiny body.

`ConfirmBars` asks for calm before the spike, which sharpens the contrast.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

The alert block sits behind `EnableAlerts`, which starts on, alongside `EnablePopup` and `EnableSound`. `EnablePushNotify` and `EnableEmail` begin false. `SoundFile` picks the clip. Detection runs on closed bars, one message per bar.

Every Non repaint spike detector Indicator input

Core settings

Setting What it does Default
ATRPeriod ATR lookback. Bars in the ATR average, default `14`. 14
RangeMult |close-open| > ATR*this. Body size threshold in ATR units, default `1.6`. 1.6
HLMult (high-low) > ATR*this. Full range threshold in ATR units, default `1.9`. 1.9
ConfirmBars prior bars to confirm calm before spike. Prior bars checked for calm before the spike, default `1`. 1

Display settings

Setting What it does Default
ArrowOffsetATR arrow offset in ATR units. Mark distance in ATR units, default `0.6`. 0.6

Alert settings

Setting What it does Default
EnableAlerts Master switch for the spike alerts, default `true`. on
EnablePopup Terminal dialog on a spike, default `true`. on
EnablePushNotify Phone push on a spike, default `false`. off
EnableEmail Mail delivery on a spike, default `false`. off
EnableSound Sound playback on a spike, default `true`. on
SoundFile Wav clip for the spike alert, default `alert.wav`. alert.wav
Non repaint spike detector indicator inputs: ATRPeriod, RangeMult, HLMult, ConfirmBars
Non repaint spike detector indicator inputs: ATRPeriod, RangeMult, HLMult, ConfirmBars

Settings that fit your chart

Spikes need instruments that actually spike. EURUSD H1 is the reference chart, where a qualifying bar usually follows a data release. On M5 they cluster around session opens. On H4 and daily whole weeks can pass without one, which is exactly what the thresholds intend.

When the Non repaint spike detector Indicator fails

A spike marks that something happened, never which way price goes afterwards.

ATR lags a sudden change in conditions, so the first spike of a busy session qualifies too easily.

One event often produces two or three qualifying bars in a row.

Copy the compiled Non repaint spike detector Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the Non repaint spike detector Indicator for MT4 and MT5

The zip holds the compiled Non repaint spike detector Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Why does the tool need both RangeMult and HLMult?

Because either test alone lets the wrong bar through. A large body with a small range is possible, and so is a huge wick with almost no body. Requiring `RangeMult` `1.6` and `HLMult` `1.9` together keeps the marks to genuinely large candles.

What do the Range Hi and Range Lo lines show?

The threshold, drawn as prices. They sit half of `HLMult` times ATR either side of the bar midpoint, so together they span the range a bar would need to qualify. A bar falling short is visibly inside them.

What does ConfirmBars at 1 check?

The bar before the spike, looking for calm rather than another large candle. It sharpens the contrast between the spike and its surroundings. Raise it to demand a longer quiet stretch, which makes marks rarer still.

Why is ArrowOffsetATR set in ATR units here?

Because a spike bar is large by definition. A fixed point offset that clears an ordinary candle would sit inside a spike. At `0.6` the mark always keeps about six tenths of a typical bar between itself and the wick.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Non repaint spike detector Indicator as one input. Always backtest before trading live.

Category: this is part of our Signal and Forecast collection. Browse more Signal and Forecast for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment