Volatility Regime Shader: Adaptive Volatility Classification for MT4/MT5
Info
The Volatility Regime Shader: Adaptive Volatility Classification for MT4/MT5 is a Indicator for MetaTrader 5 that volatility regime shader classifies market volatility into three distinct regimes, visually highlighting these on your chart background. Instead of relying on fixed Average True Range (ATR) values, this indicator calculates the percentile rank of the current ATR within a specified lookback period.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Indicator works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Indicators folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Volatility Regime Shader: Adaptive Volatility Classification for MT4/MT5
1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.
2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.
3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.
4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.
Frequently Asked Questions
Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."
Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).
Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.
What this tool does
Volatility Regime Shader classifies market volatility into three distinct regimes, visually highlighting these on your chart background.
Typical Use Case
This Indicator excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Indicator works on MetaTrader 5. Place the file in the MQL5/Indicators folder and restart the terminal.
Description & Settings
Related: AIS Average Rank Speed: Measuring Price Volatility - another powerful indicator for MetaTrader 5 traders.
Volatility Regime Shader classifies market volatility into three distinct regimes, visually highlighting these on your chart background. Instead of relying on fixed Average True Range (ATR) values, this indicator calculates the percentile rank of the current ATR within a specified lookback period. This adaptive approach ensures accurate readings across any trading symbol and timeframe, as a high percentile rank (e.g., 90%) indicates the current ATR is significantly higher than most values within the historical window.Also recommended: Volatility-Adjusted Momentum Decay Line (VAMD) - similar indicator with strong performance on MetaTrader 5.
Bars falling at or below the defined Compression threshold are shaded light blue. Bars at or above the Expansion threshold are shaded light red. By default, bars within the normal volatility range remain unshaded. An informative label in the upper-right corner displays the current volatility regime and the corresponding ATR percentile.
The identified volatility regimes can serve as a powerful filter for your trading strategies. Compression phases often precede significant price movements or breakouts, allowing breakout systems to optimize entry timing by waiting for these conditions. Expansion phases are generally more favorable for trend continuation strategies, supporting the use of wider stop-loss levels. Conversely, mean-reversion strategies typically perform best in compression or normal volatility conditions.
Input Parameters
ATR Period
The lookback period for the Average True Range (ATR) calculation, used to measure volatility. Default value is 14.
Percentile Lookback
The number of previous bars against which the current ATR value is ranked. Default value is 100.
Compression Percentile Threshold
The percentile value at or below which a bar is classified as being in a Compression regime. Default value is 20.
Expansion Percentile Threshold
The percentile value at or above which a bar is classified as being in an Expansion regime. Default value is 80.
Bars to Calculate and Shade
The number of recent bars for which calculations are performed and shading is applied. Default value is 3000.
Compression Shade Color
The background color used for the Compression volatility regime.
Expansion Shade Color
The background color used for the Expansion volatility regime.
Normal Shade Color
The background color used for the Normal volatility regime.
Shade Normal Regime
Enables or disables the background shading for bars classified as Normal volatility. Default is false.
Show Regime Label
Enables or disables the display of the current regime and ATR percentile label in the upper-right corner of the chart. Default is true.
Alerts
Configures pop-up, push, and sound alerts to notify when a newly closed bar transitions to a different volatility regime. Default is false.
Integration with Expert Advisors
Expert Advisors (EAs) can access volatility regime data through the iCustom function using two indicator buffers. Buffer 0 provides the ATR percentile (ranging from 0 to 100), and Buffer 1 provides the regime code: 0 for Compression, 1 for Normal, and 2 for Expansion. These values are also visible in the MT4/MT5 Data Window. Note that values for the currently forming bar update in real-time with price movements, while alerts are triggered only by closed bars.
You may also like: Trend BOSS: Classifying Market Regimes with Symbolic Fourier Approximation - excellent alternative for indicator users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 2
#property indicator_label1 "ATR Percentile"
#property indicator_type1 DRAW_NONE
#property indicator_label2 "Regime (0=Compression, 1=Normal, 2=Expansion)"
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.