Variance-Ratio Scoreboard: Identifying Trend vs. Choppiness Across Timeframes
Info
The Variance-Ratio Scoreboard: Identifying Trend vs. Choppiness Across Timeframes is a Indicator for MetaTrader 5 that trend or chop. A Variance-Ratio Scoreboard That Shows Whether Your Symbol Trends or Mean-Reverts on Each HorizonConceptTraders often categorize instruments as trending or choppy, influencing their strategy selection.
Usage
This tool is typically used for trend following strategies across multiple currency pairs.
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 Variance-Ratio Scoreboard: Identifying Trend vs. Choppiness Across Timeframes
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
Trend or Chop.
Typical Use Case
This Indicator excels in trend following 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: MACD Candlestick Indicator - another powerful indicator for MetaTrader 5 traders.
Trend or Chop? A Variance-Ratio Scoreboard That Shows Whether Your Symbol Trends or Mean-Reverts on Each HorizonAlso recommended: rs i ma signal indicator - similar indicator with strong performance on MetaTrader 5.
Concept
Traders often categorize instruments as trending or choppy, influencing their strategy selection. Trend-following strategies require sustained price movements, while mean-reversion strategies rely on price reversals. The variance ratio provides a measurable way to assess this behavior across different time horizons.
The variance ratio is calculated by comparing the variance of price changes over multiple periods (q-bar changes) to the variance of single-period price changes. For a random walk, where price movements are independent, the variance of a q-bar change is expected to be q times the variance of a one-bar change. Therefore, the variance ratio (VR(q)) is approximately 1.
VR(q) = variance of q-bar changes / (q x variance of one-bar changes)
A VR above 1 suggests trending behavior (moves tend to continue), while a VR below 1 indicates mean reversion (moves tend to reverse). It is important to note that a single instrument can exhibit trending behavior on one timeframe and mean-reverting behavior on another.
Calculation Details:
Returns: One-bar returns are calculated as the natural logarithm of the current close divided by the previous close. Q-bar returns are calculated similarly over q bars. These q-bar returns are overlapping, which efficiently uses data but means they are not entirely independent.
Variance: Variances are calculated around the mean return for each period, ensuring that steady drift does not artificially inflate the variance.
Horizons: The indicator analyzes five distinct time horizons, denoted as InpHorizon1 through InpHorizon5, which are configurable and increase sequentially.
Data Sets: Two sets of figures are provided: "All" represents the entire analyzed history, while "Now" uses a rolling window of the last InpWindowBars bars. This allows for the observation of market regime changes.
Z-score: The z-score quantifies how far the variance ratio deviates from 1 in terms of standard errors. The formula is: z = (VR - 1) / sqrt(2 * (2q - 1) * (q - 1) / (3 * q * n)), where n is the number of one-bar returns. The verdict is TREND if the z-score is at least InpZLimit, CHOP if it is at most negative InpZLimit, and NOISE otherwise.
The z-score calculation assumes independent returns with constant variance. In real markets, volatility clustering and fat tails can lead to a larger true standard error. Therefore, the z-score might appear higher than it should be. It's advisable to use a higher InpZLimit (e.g., above 2) and consider verdicts strong when they are consistent across horizons and data sets (all vs. now).
The indicator operates without look-ahead bias or repainting. Only closed bars are used for calculations. The calculation is incremental, maintaining running sums of returns and their squares for each horizon. New ticks require minimal computation, and historical data is not re-scanned.
Interpretation Guidelines
Indicator Lines: The indicator displays one line per horizon in the indicator window. Each line represents the variance ratio over the rolling window for each closed bar. The shortest horizon is the darkest gray, and the longest is the thickest white line. A dotted line at 1 represents the random walk benchmark. Lines above 1 indicate trending, and lines below 1 indicate mean reversion. Lines appear after a full window's worth of data has been processed.
Reading the Lines: If all lines are above 1, the symbol is trending across all analyzed horizons. If all lines are below 1, it is choppy. Mixed lines indicate a combination of behaviors (e.g., reversal on short horizons, trend on longer ones). Coordinated movements of the lines suggest a shift in market regime.
Data Panel: Located at the top-left of the chart, the panel provides detailed statistics.
Line 1: Displays the symbol, timeframe, number of analyzed returns, window length, and the z-limit for verdicts.
Line 2: Column headers.
Lines 3-7: Present the variance ratio, z-score, and verdict for each horizon, for both the entire history ("all") and the rolling window ("now"). Figures are shown as "--" until sufficient data (InpMinReturns for "all", one full window for "now") is available.
Line 8: Summarizes the number of trending, choppy, or noisy horizons for both the "all" and "now" data sets.
Line 9: A reminder on interpreting ratios and the assumptions behind the z-score.
Line 10: A single line summarizing symbol, timeframe, bar count, variance ratios for the entire history, and verdict letters (T for trend, C for chop, N for noise) for both "all" and "now" data sets, formatted for easy copying into comments.
Figure 1 illustrates a simulated H1 series that initially trends for 4,300 bars and then enters a choppy phase. The indicator lines, initially above the 1.0 line, drop below as the choppy data fills the window, with the longest horizon reacting last. The panel shows that the entire 5,000-bar history indicates a trend across all horizons, while the last 1,000 bars show choppiness on shorter horizons. (Note: This example uses simulated data.)
External Variables (Inputs)
Input
Default
Purpose
InpHorizon1
2
Horizon 1 in bars (2-500).
InpHorizon2
4
Horizon 2 in bars. Must be longer than horizon 1.
InpHorizon3
8
Horizon 3 in bars. Must be longer than horizon 2.
InpHorizon4
16
Horizon 4 in bars. Must be longer than horizon 3.
InpHorizon5
32
Horizon 5 in bars. Must be longer than horizon 4.
InpWindowBars
1000
Rolling window in bars (100-20000). Should be at least 4 times the longest horizon for sufficient data.
InpMinReturns
200
Minimum number of returns before "all" history figures are displayed (50-5000).
InpZLimit
2.5
Z-score threshold for TREND or CHOP verdicts (1-6).
InpHistoryBars
50000
Bars analyzed upon loading or full recalculation. 0 analyzes all bars. New bars are added as they arrive.
InpShowPanel
true
Determines whether to display the statistics panel.
InpColorShort
clrDimGray
Color for horizon 1 lines. Horizons 2-4 use mixed colors.
InpColorLong
clrWhite
Color for horizon 5 lines.
InpTextColor
clrSilver
Panel text color.
InpFontSize
8
Panel font size (Consolas). Line height scales with font size.
InpPanelX , InpPanelY
8, 14
Panel offset from the top-left corner of the chart in pixels.
Recommended Usage
Symbols and Timeframes: Applicable to any symbol and timeframe. The analysis is specific to the symbol and timeframe. For example, H1 and M15 will yield different results, and horizons are counted in bars of the current chart.
Compare Symbols: Use identical inputs (horizons, window, z-limit) across different symbols to compare their trending or choppy characteristics. The final line of the panel is useful for this comparison.
Review Number of Returns: A smaller window (e.g., 1000 bars) can result in noisy ratios, especially for longer horizons, as it contains fewer independent multi-bar changes. Increase InpWindowBars for smoother lines.
Short-Horizon Ratios Below 1: These are common in bar data due to factors like bid-ask bounce or thin trading. Focus on the trend of ratios across horizons rather than a single value.
Z-Score Caution: The z-score assumes ideal conditions (independent returns, constant variance). Real market data often exhibits volatility clustering and fatter tails, making the z-score potentially optimistic. Use a higher InpZLimit (e.g., 3 or more) for more conservative verdicts.
Interdependent Horizons: The verdicts for neighboring horizons are related due to shared data and overlapping calculations. Treat adjacent TREND marks as a single finding.
Analyze Full History: Adjust InpHistoryBars to examine both older and newer data segments. Discrepancies between halves of the history suggest the behavior is not a consistent characteristic of the symbol.
Ratio vs. Profit: The variance ratio indicates market behavior but does not account for trading costs (spread, swap) or entry points. It is a descriptive, not a predictive, tool.
Past Performance: The indicator describes historical data and does not forecast future price movements.
Broker Data Dependency: Results may vary slightly between brokers due to differences in data feeds, time zones, and historical data integrity.
Price Data: The indicator uses the natural logarithm of closing prices. Symbols with potential zero or negative closes (e.g., some spreads) are not fully supported; such bars are treated as having a close of 0.
Performance and Memory: Each bar is processed once with minimal computational overhead. The indicator maintains a small state and updates efficiently with new ticks.
Chart Objects: The indicator creates panel lines named VR_P in the main chart window, which are removed upon deinitialization.
Account Types: The indicator is non-trading and compatible with both netting and hedging account types.
Share Your Findings: Attach the indicator to your chart, copy the last line of the panel, and share it in the comments along with your broker's name. This allows for community comparison of trending vs. choppy instruments and discovery of surprising market behaviors. Example format: EURUSD H1 | 50000 bars | VR(all) 2:0.97 4:0.95 8:0.93 16:0.91 32:0.90 | profile all CCCNN now NNNNN .
You may also like: Delete Trade Arrows - 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_separate_window
#property indicator_buffers 5
#property indicator_plots 5
#property indicator_label1 "Variance ratio, horizon 1"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDimGray
.......
⚠ 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.