First Hour Range Day Predictor
"A big opening range means a big day" is a common trading heuristic. This script tests it directly instead of assuming it. For every completed day in the requested history it measures two numbers in pips: the range of the first InpFirstHourBars intraday bars after the day opens, and the day's own high-low range from its daily bar. It then fits dayRange = a + b * firstHourRange by hand-rolled ordinary least squares - plain double-precision sums, no external statistics library - and reports the fitted slope, intercept, R-squared and the correlation. The point of doing this with a real regression rather than eyeballing a chart is that R-squared gives an honest measure of how much of the day's eventual range the first hour actually explains, as opposed to a handful of memorable days where it happened to line up. The script prints a plain verdict alongside the numbers - no relationship, weak relationship, or meaningful relationship - based on the fitted R-squared, so the result is usable without needing to interpret a regression table by hand. A CSV of every day's first-hour range, actual day range and the regression's predicted day range is optionally written, so the fit can be checked day-by-day rather than trusted as a single summary statistic. Notes and limitations This is an ordinary least squares fit on historical data, not a live forecasting tool - it does not place trades or output a per-day prediction while running, only the fitted relationship over the sample. Using its equation to forecast a specific future day extrapolates a historical average onto one instance, with all the usual regression caveats. The script refuses to fit (and says so) when fewer than 20 usable days are available, or when the first-hour range has essentially no variance across the sample - a degenerate regression reports nothing rather than a meaningless slope. R-squared bands used for the printed verdict (below 0.05 negligible, 0.05-0.25 weak, above 0.25 meaningful) are a reasonable rule of thumb for this kind of noisy financial regression, not a universal statistical threshold - treat the printed R-squared number itself as the primary result, and the verdict as a plain-language gloss on it.
Script · MT4 · v1.0 · Free
About First Hour Range Day Predictor
First Hour Range Day Predictor is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Intraday timeframe, First hour bars and Days to study. MQL source code included.
Files in the download: FirstHourRangePredictor.mq4, FirstHourRangePredictor.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Intraday timeframe | PERIOD_M15 | Intraday timeframe used to measure the first hour |
| First hour bars | 4 | Intraday bars counted as "the first hour" (4 x M15 = 1h) |
| Days to study | 500 | Most recent completed trading days to include |
| Save csv | true | Write the per-day sample table to a CSV file |
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code