Conditional Probability Ladder
This indicator answers one narrow question honestly: out of every historical bar that shared the CURRENT bar's trend state (fast MA above or below slow MA), session (Asian/London/New York by server hour), and up/down streak length, what fraction were followed by an up close? It builds that answer by scanning InpHistoryBars of closed history once per new bar, classifying every historical bar into one of 2 (trend) x 3 (session) x 7 (streak, capped at +/-InpMaxStreak) possible state cells, and counting outcomes into each cell. The current bar's own state is then looked up in that table and shown as a plain percentage. This is a frequency table, not a model - it makes no distributional assumption and fits nothing. Its honesty comes from what it shows alongside the percentage: the actual sample count behind it. A cell with 8 historical samples and one with 400 can show the same 62% reading, and this indicator makes that difference visible (a "[thin sample]" tag and grey colouring below InpMinSamples) rather than presenting every cell with equal-looking confidence, which is the usual failure mode of frequency-table indicators that only show the percentage. A secondary "streak ladder" panel shows the same trend+session slice across every streak bucket at once, so the user can see at a glance whether P(up) trends smoothly as the streak lengthens (suggesting genuine momentum or mean-reversion structure) or jumps around (suggesting the state combination is too thin or too noisy to be useful at that particular streak length). Notes and limitations - A plain empirical frequency table over history that has already happened - it has no predictive claim beyond "this is what happened after this exact state combination historically," and past frequency is not a guarantee of future frequency. - Session buckets are approximate three-way splits by GMT hour, not each venue's exact published trading hours. - The trend classification uses a simple MA-cross state, not a strength-weighted trend measure - a fast MA barely above a slow MA is treated identically to a strongly trending one. - The frequency table rebuilds fully on every new bar rather than persisting across terminal restarts; there is no saved history between sessions.
Indicator · MT4 · v1.0 · Free
About Conditional Probability Ladder
Conditional Probability Ladder is an indicator for MetaTrader 4 based on Moving Average. It has 10 settings, such as Fast ma period, Slow ma period and Max streak. MQL source code included.
Files in the download: ConditionalProbabilityLadder.ex4, ConditionalProbabilityLadder.mq4, ConditionalProbabilityLadder.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fast ma period | 10 | Fast MA period for the trend classification |
| Slow ma period | 50 | Slow MA period for the trend classification |
| Max streak | 3 | Streak lengths beyond this are folded into the "3+" bucket |
| History bars | 2000 | Bars scanned to build the frequency table |
| Min samples | 20 | Minimum cell sample size before a probability is shown as reliable |
| Server gmt offset | 0 | Broker server time minus GMT, hours (set from the broker's spec sheet) |
| Corner | CORNER_LEFT_UPPER | Panel corner |
| X distance | 10 | Panel horizontal offset, pixels |
| Y distance | 20 | Panel vertical offset, pixels |
| Font size | 9 | Panel font size |
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: Moving Average · Trend · Trading Sessions · MT4 Indicator · MQL4 Source Code