Loading…

Volatility Ratio Adaptive Envelope

A plain percent envelope's width is a single static guess. It is too tight the moment volatility expands beyond its recent baseline - price punches through repeatedly and stops out anything using the band as a boundary - and too loose once volatility settles back down, trailing price uselessly far away and giving late, low-quality signals either way. This version replaces the fixed width with InpBaseWidthPercent multiplied by a ratio: short-period close standard deviation divided by long-period close standard deviation. When recent volatility is running above its own longer-run baseline the ratio exceeds one and the envelope widens with it; when volatility has calmed back toward baseline the ratio drops toward one and the envelope tightens back to its base width. The ratio is clamped between InpMinRatio and InpMaxRatio so one abnormal bar in the short window cannot blow the envelope out to an unusable width, and a near-silent long window cannot collapse it to nothing either. Notes and limitations - Volatility here is close-price standard deviation, not ATR - it reacts to closing price dispersion specifically, which can differ from a range-based reading during sessions with large wicks but similar closes. - Non-repainting: every bar's basis and band are computed only from that bar's own completed history. - Purely a visual envelope. It draws no arrows and sends no alerts.

Indicator · MT4 · v1.0 · Free

About Volatility Ratio Adaptive Envelope

Volatility Ratio Adaptive Envelope is an indicator for MetaTrader 4. It has 6 settings, such as Ma period, Short vol period and Long vol period. MQL source code included.

Files in the download: VolatilityRatioEnvelope.mq4, VolatilityRatioEnvelope.txt.

Settings

SettingDefaultWhat it does
Ma period20Basis simple moving average period
Short vol period10Short-term volatility window, in bars
Long vol period50Long-term (baseline) volatility window, in bars
Base width percent2.0Envelope half-width at a volatility ratio of 1.0, in percent of basis
Min ratio0.5Floor on the short/long volatility ratio, prevents the band collapsing to zero
Max ratio3.0Ceiling on the short/long volatility ratio, prevents one spike bar blowing the band out

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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 · Channels & Envelopes · Buy/Sell Arrows · Trailing Stop & Break-even · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria