Rolling Beta To Benchmark
A single, whole-history beta number hides exactly the thing a trader usually wants to know - whether a symbol's relationship to a benchmark is stable or has been quietly changing. This indicator computes beta on a rolling window instead of once, so a symbol that used to track its benchmark tightly and has recently decoupled shows that decoupling directly as the beta line moving away from its earlier level, rather than requiring a trader to notice it by eye on the price chart. Both beta and alpha are computed from bar-to-bar RETURNS, not price levels - regressing directly on price would let each instrument's own long-term drift and price scale contaminate what is supposed to be a measure of co-movement. Beta is the regression slope: how many percent the symbol has tended to move for every one percent the benchmark moved, over the current window. Alpha is the regression intercept: the average per-bar return left over once the benchmark-driven part is subtracted out - the part of performance the benchmark does not explain. Alpha is naturally a much smaller number than beta (a typical per-bar return is a small fraction of a percent), so it is multiplied by InpAlphaScaleToBp before plotting to bring it onto a comparable visual scale to beta on the same subwindow - the raw per-bar alpha in basis points, not a percentage. Notes and limitations - Both symbols are read at the same bar shift index, which assumes they share the chart's timeframe and closely aligned session hours - accurate for most forex pairs on the same broker feed, approximate when comparing across very different session hours. - Beta and alpha describe a linear, backward-looking relationship over the chosen window; neither is a forecast, and both can change quickly around news events or session changes. - Values are computed from closed bars only (the window always ends one bar in the past relative to the bar being evaluated), so nothing plotted here repaints on a later tick. - No alerting in this version; it is a continuously updating analytic line intended to be read rather than to trigger on a single event.
Indicator · MT4 · v1.0 · Free
About Rolling Beta To Benchmark
Rolling Beta To Benchmark is an indicator for MetaTrader 4. It has 4 settings, such as Benchmark symbol, Symbol suffix and Lookback bars. MQL source code included.
Files in the download: RollingBetaToBenchmark.ex4, RollingBetaToBenchmark.mq4, RollingBetaToBenchmark.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Benchmark symbol | EURUSD | Benchmark symbol regressed against |
| Symbol suffix | Broker suffix appended to InpBenchmarkSymbol, leave blank if none | |
| Lookback bars | 100 | Regression window, in closed bar-to-bar returns |
| Alpha scale to bp | 10000.0 | Multiplier turning per-bar alpha into basis points for the chart |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: MT4 Indicator · MQL4 Source Code