Loading…

Deviation Scaled Moving Average

A fixed period moving average always trades reactivity for smoothness at one constant rate, no matter what price is actually doing. DSMA changes the rate on the fly by measuring how unusual the current move is before deciding how much to react to it. It runs a SuperSmoother - the same 2-pole Butterworth-style low pass used across Ehlers' filter work - on the 2-bar momentum of price rather than on price itself, which produces a smooth, roughly zero-mean deviation series. That deviation is then divided by its own root-mean-square over the lookback period, turning an arbitrary-scale number into something closer to a bounded z-score: how many "typical deviations" is the current move. The moving average's smoothing constant is set directly from that scaled value, so a genuinely large, fast move opens the average right up to track it, while ordinary back-and-forth noise around the same size as recent history keeps the average close to flat. The result behaves like an adaptive average without needing to estimate a market cycle first, the way MAMA does - it reacts to the size of the current deviation relative to its own history, which is a simpler and more directly interpretable adaptation rule for traders who want responsiveness tied to move size rather than to cycle phase. Notes and limitations - Needs roughly InpPeriod plus a handful of bars of history before the RMS normalisation window is fully populated; earlier bars are seeded flat. - The RMS window is recomputed by direct summation each bar rather than carried forward as a running sum, the same trade-off made in the Correlation Trend Indicator submission - simpler and safe against floating point drift at the lookback lengths this is meant to run at. - Like any adaptive filter, it can only judge "unusual" relative to its own recent history - a period that has been unusually calm will have a low RMS baseline, so a moderate move right after it can look larger to the indicator than it would after a genuinely volatile stretch. - Fully causal and recursive: no repainting, every plotted value for a closed bar is final.

Indicator · MT5 · v1.0 · Free

About Deviation Scaled Moving Average

Deviation Scaled Moving Average is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Period and Alerts. MQL source code included.

Files in the download: DeviationScaledMovingAverage.ex5, DeviationScaledMovingAverage.mq5, DeviationScaledMovingAverage.txt.

Settings

SettingDefaultWhat it does
Period20SuperSmoother cutoff and RMS normalisation lookback, in bars
AlertstrueAlert once per closed bar when price crosses DSMA

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Moving Average · Momentum · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria