Draw Round Number Grid
Round numbers act as informal support and resistance because enough other traders are watching the same tidy figures - 1.1000, 1900.00, 35000. Drawing that grid by hand, symbol by symbol, means remembering a different spacing for every instrument you trade. The naive version of this script asks for one step in pips and applies it everywhere, which is wrong the moment you switch from EURUSD to gold or an index - the step that makes sense for a 5-digit FX pair is meaningless on an instrument quoted in the thousands. This script derives a default instead. Anything quoted the classic FX way - 3 or 5 digit, majors and JPY crosses alike once the pip conversion is applied - gets 50 pips. Everything else gets roughly 0.2% of the current price, snapped to the nearest 1, 2 or 5 times a power of ten: the same "nice number" logic charting software uses to pick axis gridlines. That formula lands on 5.00 for gold near 2600 and 50 for an index near 35000 without a lookup table keyed to symbol names, which would break the moment a broker used an unexpected suffix. The auto step cannot always be right - a metal and an index can sit at a similar price and get the same guess - so it is a default, not a promise, and the step input overrides it outright. The major/minor split is keyed to the level itself, not to its position on screen: a line is "major" when its index on the step grid is a multiple of the chosen number, so the same levels are always solid regardless of how far the chart happens to be scrolled when the script runs. Notes and limitations - The auto step is a heuristic, not a lookup table for your specific broker. It can pick the same step for a metal and an index sitting at a similar price; the step input is there for exactly that case. - A safety cap stops the script at 500 lines. A step set far too small for the visible range and margin will hit this cap and log a warning rather than flooding the chart with objects. - The visible price range comes from the chart at the moment the script runs. Scrolling or zooming afterwards does not redraw the grid - run the script again if you want it to follow a new view. - Lines are named after their own price, so re-running with a different step after cleanup is off can leave a mix of old and new spacing on the chart; leave InpCleanupFirst on unless you specifically want that.
Script · MT4 · v1.0 · Free
About Draw Round Number Grid
Draw Round Number Grid is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Step points, Margin pips and Major every. MQL source code included.
Files in the download: DrawRoundNumbers.ex4, DrawRoundNumbers.mq4, DrawRoundNumbers.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Step points | 0 | Step, in points (0 = auto from digits/price) |
| Margin pips | 20 | Margin beyond the visible price range, in pips |
| Major every | 2 | Every Nth level drawn solid; others dotted |
| Line color | clrDimGray | Line colour (style tells major from minor) |
| Cleanup first | true | Delete this script's previous grid first |
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: Gold (XAUUSD) · Grid · Support & Resistance · EURUSD · Alerts · MT4 Script · MQL4 Source Code