Compression Day Base Rate Table
"Compression precedes expansion" is a common piece of trading folklore, usually pointed at inside days or NR7 setups. This script checks it directly rather than repeating it: every historical day is flagged as an inside day (today's High/Low sits entirely inside yesterday's) and separately as an NR7 day (today's range is the smallest of the trailing InpNR7Window days, today included), and for every day - flagged or not - the actual next day's range is compared against today's. Three groups are reported side by side: All Days (the baseline), Inside Days, and NR7 Days. Each gets a count, its frequency as a percentage of all days studied, the average and median next-day expansion ratio (next day's range divided by today's range), and the percentage of occurrences where the next day's range genuinely exceeded today's. Put next to the All Days baseline, this shows directly whether compression flags actually raise the odds of next-day expansion on this specific symbol, rather than assuming the folklore holds everywhere equally. Notes and limitations A day with zero range, or whose next day also has zero range, is excluded from every group (including the All Days baseline) since no genuine expansion ratio can be computed for it. Ties count: if today's range equals the narrowest range in the trailing window (rather than being strictly the smallest), it is still flagged NR7. This matches how the setup is commonly read in practice. This is a historical base-rate table, not a forecast for tomorrow. A group whose average expansion ratio is above 1.0 in the sample can still fail to expand on any specific occurrence; treat the percentages as context, not a trigger.
Script · MT5 · v1.0 · Free
About Compression Day Base Rate Table
Compression Day Base Rate Table is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Days to study, Nr7 window and Save csv. MQL source code included.
Files in the download: CompressionDayBaseRates.ex5, CompressionDayBaseRates.mq5, CompressionDayBaseRates.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Days to study | 1000 | Most recent completed trading days to include |
| Nr7 window | 7 | Trailing window (in days, today included) for the narrowest-range flag |
| Save csv | true | Write the per-group table to a CSV file |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Trailing Stop & Break-even · Alerts · MT5 Script · MQL5 Source Code