波動性 VolatilityFilterRegime 在 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

示意性 — 合成資料,非即時報價。

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
顯示公式與計算詳情

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.

訊號

StdDev 提供的可回測訊號 — 及每個訊號適合的市場狀態。

Contraction

Builder 可實現
條件
A short-window deviation falls below a longer one
最佳市場狀態
Ranging / pre-breakout
典型用法
Permit mean-reversion, or wait for expansion

Expansion

Builder 可實現
條件
A short-window deviation rises above a longer one
最佳市場狀態
Breakouts
典型用法
Confirm a move is spreading rather than drifting

Regime Comparison

進階邏輯
條件
Current deviation against its own recent range
最佳市場狀態
Any
典型用法
Switch strategy behaviour between calm and violent regimes

Band Width Proxy

Builder 可實現
條件
Deviation used in place of a Bollinger width calculation
最佳市場狀態
Any
典型用法
Express a squeeze rule that iBands cannot supply directly

MT5 實作

MetaTrader 5 實際計算與繪製的內容——本頁每條規則的依據。

緩衝區

索引 緩衝區 MT5 中的繪製方式 存放內容
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.

平台說明

最佳適用場景 / 謹慎使用

沒有任何指標具有普適優勢。以下是 StdDev 發揮作用的場景 — 以及可能誤導的場景。

最佳適用場景

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

謹慎使用

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

構建 StdDev 策略

將訊號接入進場和出場規則,然後匯出可編譯的 MT5 EA — 無需撰寫程式碼。

  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

將 StdDev 與其他指標組合

單一指標很少獨立有效。這些組合彌補了 StdDev 的盲點。

StdDev + MFI

  1. Fast StdDev below slow
  2. MFI below 20
  3. Buy
原因
Let dispersion decide whether mean reversion is allowed, and let the flow oscillator decide the direction of the fade
最佳市場狀態
Ranging
構建此策略 →

StdDev + Bollinger Bands

  1. StdDev at a local low
  2. Price at a band
  3. Wait for expansion
原因
Supply the band-width reading iBands does not publish, so a squeeze rule can be written without computing upper minus lower
最佳市場狀態
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.

開啟 Builder →

StdDev + Moving Average

  1. Fast StdDev above slow
  2. Fast MA crosses slow
  3. Buy
原因
Take direction from the trend and permission from dispersion, so a crossover only fires when the market is actually moving
最佳市場狀態
Trending

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

開啟 Builder →

參數

在您自己的貨幣對和時間框架上驗證的起始值 — 非保證設置。

參數 預設值 建議測試範圍 功能說明
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.

初始預設

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

市場示例

StdDev 有效的場景、失效的場景,以及篩選器如何改變結果。

有效

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.

失效

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.

已篩選

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

關鍵術語