Bayesian Up Probability Meter
A rolling "percent of up bars" figure treats every bar in the window as equally informative and falls off a cliff the instant an old bar rolls out of the window. This indicator instead keeps a running Beta(alpha, beta) posterior over the probability of an up bar: each closed bar is one Bernoulli trial (close above open counts as a success), and before folding in that trial the running alpha and beta are both multiplied by a decay factor, so old evidence fades smoothly rather than dropping out abruptly at a fixed window edge or accumulating forever unbounded. The posterior's own analytic mean and variance are used to plot both the point estimate and a credible band, so a reading of "62% up" that rests on a handful of decayed trials looks visibly less certain than the same 62% resting on a long, consistent run. JUDGEMENT CALL: MQL4 has no Beta-distribution quantile function, and this catalogue has no incomplete-beta implementation to reuse (the closest precedent, AutocorrelationTools.mqh's Abramowitz-Stegun approximation, computes a normal tail probability, not a Beta one). Rather than hand-roll an incomplete-beta solver for a MEDIUM-effort indicator, the plotted credible band is an honestly-labelled normal approximation to the Beta posterior - mean plus or minus z times the posterior's own standard deviation, clipped to [0, 1]. This is a standard textbook approximation and is accurate once alpha and beta are both reasonably large; it degrades early in the series, right after a fresh attach, or after heavy decay has pulled both counts down towards the prior. That degradation is honest and expected, not a bug. Notes and limitations The credible band is a normal approximation to a Beta posterior, not an exact Beta quantile - see the judgement call above. This meter measures bar-close direction only (close versus open); it says nothing about the SIZE of the expected move, only its sign's probability. The recursion is recomputed over a bounded window on every closed bar (see InpMaxPlotBars), starting fresh from the prior at the oldest bar in that window, so very old history beyond the window does not influence the plotted values - this is a deliberate bound, not a memory of true full history.
Indicator · MT4 · v1.0 · Free
About Bayesian Up Probability Meter
Bayesian Up Probability Meter is an indicator for MetaTrader 4. It has 5 settings, such as Prior alpha, Prior beta and Decay factor. MQL source code included.
Files in the download: BayesianUpProbability.ex4, BayesianUpProbability.mq4, BayesianUpProbability.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Prior alpha | 1.0 | Prior alpha (successes) - 1,1 is a flat/uniform prior |
| Prior beta | 1.0 | Prior beta (failures) - 1,1 is a flat/uniform prior |
| Decay factor | 0.98 | Per-bar decay applied to accumulated evidence (0.90-1.0) |
| Credible level | 0.90 | Credible interval level: 0.80, 0.90, 0.95 or 0.98 |
| Max plot bars | 300 | History bars kept recomputed (performance cap) |
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