MT5 Grid Optimizer & ATH Scanner – Pending Order Analyzer & Range Expansion Tool
July 16, 2026 • 12 min read • MT5 Tools, Grid Trading, Market Scanning, Pending Orders
Most traders place pending orders based on gut feeling or round-number levels. The GridOptimizer and ATH Scanner are two professional-grade MT5 scripts that replace guesswork with data-driven analysis. Unlike Expert Advisors that trade automatically, these are analytical tools you run once on a chart to extract actionable intelligence from historical price data.
The GridOptimizer analyzes 90 days of H1 data to find the statistically optimal Buy Limit, Sell Limit, Buy Stop, or Sell Stop level for the current market. It considers market regime (trending vs ranging), swing point clusters, ATR-proportional stop/target distances, and simulates every possible entry across thousands of historical bars to score each level by weighted win rate.
The ATH Scanner is a 27-pair market scanner that detects when a pair is trading at a 90-day all-time-high while simultaneously experiencing its largest daily range in 90 days — a powerful confluence suggesting explosive directional momentum. Results are displayed instantly in the Experts tab and saved to a timestamped CSV file.
GridOptimizer — Optimal Pending Order Level Finder
How It Works
The GridOptimizer is the most comprehensive pending-order analysis tool available as a free MT5 script. It transforms 90 days of H1 price data into a single actionable recommendation: where to place your next Buy Limit, Sell Limit, Buy Stop, or Sell Stop — backed by statistical evidence.
Core Analysis Pipeline
1. Regime Detection
Splits 90 days into 3 equal periods. If the price shift exceeds 1.5x ATR, the market is labeled trending; otherwise ranging. Trend-following orders get a 1.3x score bonus; counter-trend orders receive a 0.5x penalty.
2. Swing Point Detection
Identifies all significant swing highs and lows using 3-bar left/right confirmation. Duplicate swings within 0.4x ATR are merged (stronger one kept). Every entry level is validated against nearest swing for SL/TP placement.
3. Historical Simulation
Every potential entry level (stepped at 0.15x ATR intervals) is simulated across all historical bars. Each trigger is followed forward up to 168 bars. Recent data weighted 3x, mid-range 2x, old data 1x for a decay-weighted win rate.
The Scoring Formula
Score = WR² × R:R × TrendBonus × RegimePenalty × EntryReasonability × Consistency × ClusterBonus
Where:
WR = Decay-weighted win rate (recent 33% weighted 3x)
R:R = TP pips / SL pips (higher = better)
TrendBonus = 1.3 if aligned with 200 MA, 0.7 if against
RegimePenalty = 0.5 if counter-trend in trending market
EntryReasonability = 1.0 within 1.5x ATR, 0.6 within 2x ATR, 0.3 beyond
Consistency = 1.0 if 30+ triggers, 0.8 if 20+, 0.6 if 10+
ClusterBonus = Up to 1.5x based on swing cluster density near entry
Key Features
Buy Limit, Sell Limit, Buy Stop, Sell Stop — all four tested simultaneously. The best setup across all types is highlighted with a ★ marker.
Detects trending vs ranging regimes by comparing early, mid, and late 30-day price zones. Automatically penalizes counter-trend entries in trending markets.
Stop loss and take profit are always placed at the nearest confirmed swing point. If the swing distance is too small, it expands to the minimum ATR-based distance.
Recent 30 days weighted 3x, middle 30 days 2x, oldest 30 days 1x. Ensures the score reflects current market behavior more than ancient history.
Draws the best entry level (blue dashed), stop loss (red dashed), and take profit (green dashed) directly on the chart with pips labels and confidence tag.
All parameters are adjustable: lookback period, ATR scan range, step size, minimum triggers, max hold bars, SL/TP ATR multiples, trend MA period, and swing significance.
Input Parameters
| Parameter | Default | Description |
|---|---|---|
| InpLookbackDays | 90 | Historical data lookback period |
| InpTimeframe | PERIOD_H1 | Data timeframe for analysis |
| InpScanRangeATR | 2.5 | Max entry distance from current price in ATR |
| InpScanStepATR | 0.15 | Step between scan levels in ATR |
| InpMinTriggers | 10 | Minimum historical triggers required |
| InpMaxHoldBars | 168 | Max bars to wait for TP/SL after trigger |
| InpMinSL_ATR | 0.8 | Minimum stop loss distance in ATR |
| InpMinTP_ATR | 1.2 | Minimum take profit distance in ATR |
| InpTrendMAPeriod | 200 | MA period for trend alignment check |
| InpSwingMinATR | 0.4 | Minimum swing significance in ATR |
| InpDrawOnChart | true | Draw best entry levels on chart |
How to Interpret Results
The script outputs a table comparing all four order types side by side. Look for HIGH confidence setups with at least 20 historical triggers and a win rate above 55%. A ★ next to the entry label on the chart indicates the highest-scored setup. If no setup meets minimum criteria, the script warns you and suggests parameter adjustments. Rerun on different symbols or after market shifts.
ATH Scanner — 90-Day All-Time-High Range Expansion Detector
How It Works
The ATH Scanner is a multi-pair scan script that screens 27 major and cross forex pairs for a specific high-probability breakout pattern: price trading at or near a 90-day all-time-high while simultaneously experiencing a daily range that exceeds every daily range in the past 90 days. This dual-confluence signals that momentum is breaking out in a statistically significant way.
Unlike oscillators or lagging indicators, the ATH Scanner is a pure price-action scanner that identifies when a pair is doing something it has not done in 90 days — both in terms of price level and volatility expansion. This is the type of setup institutional traders monitor for breakout continuation strategies.
27 Scanned Pairs
| Majors | Crosses (EUR) | Crosses (GBP) | Crosses (JPY) | Crosses (Other) |
|---|---|---|---|---|
| EURUSD, GBPUSD, USDJPY, USDCHF, AUDUSD, NZDUSD, USDCAD | EURGBP, EURJPY, EURCHF, EURAUD, EURNZD | GBPJPY, GBPCHF, GBPAUD, GBPNZD, GBPCAD | CHFJPY, AUDJPY, NZDJPY, CADJPY | AUDNZD, AUDCAD, EURCAD, NZDCAD, AUDCHF, NZDCHF |
Key Features
All major forex pairs plus key cross rates automatically scanned in a single run. Smart symbol resolution detects broker-specific suffixes (m, .pro, fx, etc.).
Requires BOTH conditions: price at 90-day ATH (within 0.01% tolerance) AND today's range exceeding every daily range in the past 90 days.
All matching pairs are saved to a timestamped CSV file (e.g., ATH_Scan_2026_07_16.csv) with pair, ask, ATH, today range, max 90d range, expansion %, and ATH-to-low pips.
Formatted output with pair numbering, ask price, ATH level, today range in pips, max 90d range, expansion percentage, and ATH-to-low pips. Non-matching pairs with errors are listed as skipped.
Input Parameters
| Parameter | Default | Description |
|---|---|---|
| InpPairs | 27 pairs | Comma-separated list of base pairs to scan |
| InpLookbackDays | 90 | Number of days for ATH and max range calculation |
How to Trade ATH Scanner Results
When a pair appears in the scan results, it means price is at a 90-day high AND volatility is expanding beyond every other day in 90 days. This is a high-momentum breakout signal. Bullish approach: look for a pullback to the previous day's high (now support) for a limit entry. Bearish approach: a daily close below the ATH level suggests a false breakout — consider fading the move. Always combine with your broader market context (USD index, risk sentiment).
How to Use MT5 Scripts
These are scripts, not Expert Advisors. They run once and terminate. Here is how to use them:
- Download the .ex5 file(s) from the section below.
- Open your MT5 terminal and go to File → Open Data Folder → MQL5 → Scripts.
- Paste the .ex5 file(s) into the Scripts folder and restart MT5.
- For GridOptimizer: drag it onto your desired symbol's chart (H1 recommended). Review input parameters and click OK. Results appear in the Experts tab.
- For ATH Scanner: drag onto any chart (symbol doesn't matter — it scans 27 pairs automatically). Click OK. Results appear in the Experts tab and a CSV file is saved in the Files folder.
Free Download — MT5 .ex5 Scripts
Download the compiled scripts for free. No registration or email required. Simply download, install in your Scripts folder, and drag onto any chart.
Source Code — Only $30
The free .ex5 files above are fully functional compiled scripts. For traders and developers who want to study, modify, or customize the logic, we offer the complete MQL5 source code:
- GridOptimizer.mq5 — Full source with 720+ lines of documented MQL5 code including regime detection, swing analysis, and scoring engine.
- ATH_Scanner.mq5 — Complete scanner source with smart symbol resolution and CSV export.
- Both for $30 — Includes the right to modify for personal use.
To purchase: enquiry@algospecial.com or use our contact form. White-label rebranding and custom modifications also available.
Frequently Asked Questions
Are these Expert Advisors or Scripts?
They are MT5 scripts, not EAs. Scripts run once when dropped on a chart and then stop. They do not execute trades automatically. The GridOptimizer analyzes data and outputs a recommendation; the ATH Scanner scans 27 pairs and reports matches.
Can the GridOptimizer place orders for me?
No. It is an analytical tool only. It identifies the statistically optimal pending order level based on historical data. You must manually place the order. This design ensures you maintain full control over trade execution.
Do the ATH Scanner results guarantee a breakout?
No scanner guarantees a breakout. The ATH Scanner identifies when a pair is at a 90-day high with expanding range — a statistically significant confluence often seen at the start of major directional moves. Always use your own risk management and confirm with higher-timeframe context.
How often should I run the GridOptimizer?
Run it daily or after major economic events. The scoring changes as new price data enters the 90-day window and market regime shifts. Running it once per trading session gives you fresh, data-driven levels.
Why does the ATH Scanner report a symbol not found?
Different brokers use different symbol suffixes (e.g., EURUSDm, EURUSD.pro, EURUSD.fx). The script tries common suffixes automatically. If your broker uses an unusual suffix, add it to the supported suffixes list in the source code — available for $30.
Can I buy the source code for only one script?
Yes. Source code is $30 for both or $20 for individual scripts. Contact enquiry@algospecial.com for single-script pricing.