Trend Day Frequency Classifier
"Was today a trend day?" is usually answered by eye, which means two people looking at the same chart can disagree, and nobody can tell you the base rate. This script replaces the judgement call with three fixed rules, applied identically to every day in the studied history: TREND: the day's net move relative to its own range, |Close-Open| / (High-Low), is at or above InpTrendRatio. The day closed near one extreme with a strong directional push. REVERSAL: the day's DOMINANT intraday extreme - whichever of the High or the Low deviates further from the Open - formed in the first half of the session, yet the close finished on the OPPOSITE side of the Open by at least InpReversalRatio of the day's range. Price ran one way early, then gave it back and then some. RANGE: everything else - the fallback bucket for days that are neither a strong net mover nor a clear early-extreme-then-reverse day. Locating WHEN within the day the high or low actually formed re-uses the day-boundary and intraday-bar-search technique from HighLowTimeOfDay.mq4 elsewhere in this catalogue: a daily bar only records the day's High and Low VALUES, not when within the day they printed, so an intraday timeframe is scanned across each calendar day to find the specific bar that carries each extreme, and that bar's position within the day (first half or second half) drives the Reversal test. The output is a weekday x class table (Monday through Friday), each cell a count plus a percentage of that weekday's total, so a pattern like "Fridays classify as Range far more often than Mondays" is visible directly rather than assumed. Notes and limitations A day is skipped entirely (not counted in any class) if it has zero range, or if no intraday bar can be matched inside its boundaries (a data gap on the intraday timeframe) - the day count reported can be lower than InpDaysToStudy for that reason, especially with a wide intraday timeframe and deep history requested. The three rules are deliberately simple and threshold-based, chosen for being checkable and repeatable rather than for matching every trader's intuition of "trend day" exactly. A day that is genuinely borderline can land in Range even if it subjectively "felt" like a mild trend - that is the fallback bucket doing its job, not a bug. This is a base-rate study over history, not a same-day prediction. A weekday that trended often in the sample can still range on any given occurrence.
Script · MT5 · v1.0 · Free
About Trend Day Frequency Classifier
Trend Day Frequency Classifier is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Intraday timeframe, Days to study and Trend ratio. MQL source code included.
Files in the download: TrendDayFrequency.ex5, TrendDayFrequency.mq5, TrendDayFrequency.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Intraday timeframe | PERIOD_M15 | Intraday timeframe used to locate the high/low bar |
| Days to study | 500 | Most recent completed trading days to include |
| Trend ratio | 0.60 | |Close-Open|/(High-Low) at/above this => TREND |
| Reversal ratio | 0.25 | Close beyond this fraction of range past Open (opposite the early extreme) => REVERSAL |
| Save csv | true | Write the weekday x class 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: Trend · Alerts · MT5 Script · MQL5 Source Code