Custom Interval Time Grid Drawer
The terminal's built-in chart grid only ever lines up with the bar timeframe itself. A trader working a cycle that does not match any standard period - a custom session length, a broker's non-round rollover time, a strategy-specific interval such as "every 90 minutes from the Monday open" - has no way to see it without manually placing vertical lines one at a time. This script walks forward and backward from one anchor timestamp in fixed-minute steps and places the whole grid in a single pass, using OBJ_VLINE objects that persist on the chart after the script exits. The anchor line itself is drawn thicker and solid so it stays visually distinct from the repeating grid around it, and can carry an optional text label showing the anchor date/time. Re-running the script with different inputs first removes every line it previously drew (matched by its own object name prefix), so changing the interval or anchor never leaves a stale grid mixed in with the new one. Notes and limitations - Line count is fixed by InpLinesBackward/InpLinesForward, not by the visible chart window - a short interval with a high line count can draw well past what is currently visible; scroll or zoom out to see the full extent, or reduce the counts. - This draws chart objects only; it does not attach to or move with a changing timeframe beyond what OBJ_VLINE already does natively (the lines stay fixed to their absolute time, correctly, across timeframe changes). - Object cleanup on re-run is prefix-based and works reliably, but manually deleting individual grid lines from the chart's Objects list will not be detected - a full re-run always restores the complete grid.
Script · MT5 · v1.0 · Free
About Custom Interval Time Grid Drawer
Custom Interval Time Grid Drawer is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Anchor time, Interval minutes and Lines backward. MQL source code included.
Files in the download: CustomTimeGridDrawer.ex5, CustomTimeGridDrawer.mq5, CustomTimeGridDrawer.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Anchor time | D'2024.01.01 00:00' | Anchor time the grid is measured from |
| Interval minutes | 90 | Repeat interval, minutes |
| Lines backward | 40 | Lines to draw before the anchor |
| Lines forward | 40 | Lines to draw after the anchor |
| Line color | clrDarkGray | Line colour |
| Line style | STYLE_DOT | Line style |
| Label anchor line | true | Put a text label on the anchor line itself |
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: Grid · Trading Sessions · Alerts · MT5 Script · MQL5 Source Code