Volatility VolatilityFilterRegime Available in Builder

Standard Deviation

Standard Deviation measures how widely price is scattered around its own moving average — the raw dispersion figure that Bollinger Bands are built from. On its own it is the cleanest way to ask whether a market is expanding or contracting, with no direction attached.

Template period
20
Direction
None
Units
Price
OverboughtOversoldCentreline 50Divergence

Illustrative — synthetic data, not a live quote.

What Standard Deviation tells you

Standard Deviation answers how far, on average, price has been sitting from its own recent average. A rising value means the market is spreading out; a falling one means it is compressing. Like ATR it carries no direction — but unlike ATR it measures dispersion around a mean rather than distance travelled per bar.

  • Rising: price is spreading away from its mean
  • Falling: the market is compressing toward it
  • Zero direction — expansion looks identical up or down
  1. 1 Average the applied price over N bars
  2. 2 Measure each bar's distance from that average
  3. 3 Take the root mean square of those distances
Show the formula & calculation detail

Standard Deviation is the textbook dispersion statistic, computed on a rolling window:

  1. Compute a moving average of the applied price over the period, using the chosen method.
  2. For each bar in the window, take the difference between its price and that average, and square it.
  3. Average the squared differences and take the square root: σ = √( Σ(Pᵢ − MA)² / N ).

Squaring in step 2 is what makes the result directionless — a price 10 points above the average and one 10 points below contribute identically. It also means large excursions dominate: doubling a single bar’s distance quadruples its contribution, so the reading responds sharply to one outsized bar and then decays as that bar leaves the window.

The output shares the instrument’s price units, which is both useful and limiting. Useful, because the number is directly comparable to a distance on the same chart. Limiting, because a threshold written for one symbol means nothing on another — which is why rules are almost always written as one deviation against another rather than against a fixed number.

In MQL5 the call is iStdDev(symbol, period, ma_period, ma_shift, ma_method, applied_price) and it returns a handle to a single buffer. Both ma_method and applied_price are real arguments, so the average the dispersion is measured around is as configurable as a standalone moving average.

Signals

The distinct, backtestable signals StdDev gives — and the regime each one suits.

Contraction

Builder ready
Condition
A short-window deviation falls below a longer one
Best regime
Ranging / pre-breakout
Typical use
Permit mean-reversion, or wait for expansion

Expansion

Builder ready
Condition
A short-window deviation rises above a longer one
Best regime
Breakouts
Typical use
Confirm a move is spreading rather than drifting

Regime Comparison

Advanced logic
Condition
Current deviation against its own recent range
Best regime
Any
Typical use
Switch strategy behaviour between calm and violent regimes

Band Width Proxy

Builder ready
Condition
Deviation used in place of a Bollinger width calculation
Best regime
Any
Typical use
Express a squeeze rule that iBands cannot supply directly

MT5 implementation

What MetaTrader 5 itself computes and draws — the reference every rule on this page is written against.

Buffers

Index Buffer Drawn in MT5 as What it holds
0 MAIN_LINE Line The standard deviation of the applied price around its own moving average, in price units. Always positive; it has no zero line and no upper bound.

Platform notes

Works best / use carefully

No indicator is a universal edge. Here is where StdDev helps — and where it misleads.

Works best

  • As a volatility filter
  • Expressing squeeze rules
  • Comparing regimes on one instrument
  • Alongside a directional signal

Use carefully

  • As a directional signal
  • Comparing raw values across instruments
  • Fixed price thresholds
  • Very short periods on low timeframes

Build a strategy with StdDev

Wire the signal into entry and exit rules, then export a compilable MT5 EA — no code.

  1. Fast StdDev (10)
  2. Slow StdDev (40)
  3. Fast below slow — a quiet market
  4. MFI below 20 in a quiet market → Open Buy · SL 40 / TP 80
  5. MFI above 80 in a quiet market → Open Sell

Combine StdDev with other indicators

One indicator rarely stands alone. These pairings cover StdDev's blind spots.

StdDev + MFI

  1. Fast StdDev below slow
  2. MFI below 20
  3. Buy
Why
Let dispersion decide whether mean reversion is allowed, and let the flow oscillator decide the direction of the fade
Best regime
Ranging
Build this strategy →

StdDev + Bollinger Bands

  1. StdDev at a local low
  2. Price at a band
  3. Wait for expansion
Why
Supply the band-width reading iBands does not publish, so a squeeze rule can be written without computing upper minus lower
Best regime
Pre-breakout

No single-flow template pairs Standard Deviation with Bollinger Bands. Start from Bollinger Bounce and add StdDev nodes with a Compare between a fast and a slow period.

Open Builder →

StdDev + Moving Average

  1. Fast StdDev above slow
  2. Fast MA crosses slow
  3. Buy
Why
Take direction from the trend and permission from dispersion, so a crossover only fires when the market is actually moving
Best regime
Trending

No single-flow template pairs Standard Deviation with a moving average. Start from MA Crossover and add StdDev nodes with a Compare.

Open Builder →

Parameters

Starting values to validate on your own pair and timeframe — not guaranteed settings.

Parameter Default Suggested test range What it does
Period 20 10–50 Window for both the moving average and the dispersion measured around it. The template uses 10 and 40 as a fast/slow pair rather than a single value.
Method SMA SMA / EMA / SMMA / LWMA How the underlying average is weighted. Changing it changes what the deviation is measured around, so it changes the output even at the same period.
Applied price Close Close / Open / High / Low / Median / Typical / Weighted Price series the dispersion is computed on. iStdDev accepts any ENUM_APPLIED_PRICE value.
Shift 0 0–3 Which bar back the value is read from. Shift 1 compares against a fully closed bar.

Starting presets

Reactive 10 Responds within the session
Standard 20 Matches the Bollinger default window
Regime 40 Describes the week, not the bar

Market examples

Where StdDev works, where it fails, and how a filter changes the outcome.

Works

Contraction permits the fade

The short-window deviation falls under the long one, the market is genuinely quiet, and a mean-reversion entry works as intended.

Fails

Fading into an expansion

The same oscillator extreme appears while dispersion is climbing. Price is spreading away from its mean, and the fade is standing in front of it.

Filtered

Dispersion filter suppresses the trade

The directional signal fires but the fast deviation sits above the slow one, so the entry is skipped and the move continues without you.

FAQ

Standard Deviation or ATR?
They are different measurements that often agree. ATR averages the distance price travelled per bar and includes gaps; Standard Deviation measures how scattered prices are around their own average and ignores gaps entirely. Use ATR when you care about how much room a trade needs, and Standard Deviation when you care about whether the market is spreading out or compressing.
Is this the same σ that Bollinger Bands use?
Yes. Bollinger's outer bands are the middle band plus and minus a multiple of exactly this quantity, computed over the same window on the same applied price. That is why Standard Deviation is the practical way to write a squeeze rule — iBands publishes the three lines but not the width between them.
Why is there no zero line?
Because dispersion cannot be negative — the calculation squares each distance before averaging. The indicator is always at or above zero and has no upper bound, so rules are written as comparisons between two deviations or against the indicator's own recent range, never against a fixed centre.
What period should I use?
20 matches the Bollinger default and is a sensible single-value starting point. In practice a fast/slow pair is more useful than any single number, because it removes the need for an instrument-specific threshold — the template uses 10 against 40 for exactly that reason.
Can I build a Standard Deviation EA without coding?
Yes, as a filter. The MFI + Standard Deviation template uses two StdDev nodes with different periods and a Compare between them to require a quiet market, with period, method and applied price exposed as EA inputs. Classifying volatility against its own long-run distribution is the exception and needs custom MQL5.
How should I validate settings before going live?
Backtest on quality tick data first, then run the EA on a demo account before risking money. When optimising, hold back data the search never saw and prefer settings that stay profitable across periods over the single in-sample peak — chasing that peak is overfitting the noise. No default or preset here is a performance promise; every value is a starting point to re-validate on your own pair and broker.

Glossary

Key terms