Exit Grid Sweep Harness
Finding a good stop/target pair normally means running one Strategy Tester optimisation pass per combination, or hand-editing inputs and re-running. This harness answers the same question in a single pass: every time the fixed fast/slow MA cross fires an entry signal, it walks the price path that has ALREADY elapsed since that entry forward, bar by bar, and checks every stop/target pip combination in the configured grid against that same path at once, since High/Low data for past bars costs nothing extra to re-check per combination. A signal is only scored once enough bars have passed since its entry for the whole grid to be evaluated fairly - nothing here ever looks at a bar that has not closed yet. If neither the stop nor the target is reached within the hold window, the combination is marked to market at the close of the last bar considered instead of being discarded, so a too-tight grid still produces an honest (if noisy) number rather than silently dropping the sample. The result is written as a CSV grid - stop pips down the rows, target pips across the columns, average R per cell - that pastes straight into a spreadsheet heatmap. Notes and limitations - Report-only. This EA places no orders and manages no positions; every "trade" is a hypothetical walk over already-closed bars. - If a bar's High and Low both cross their respective stop and target levels within the same bar, the stop is assumed to have been hit first. This is the conservative assumption used throughout this catalogue - it can only understate a combination's performance, never overstate it. - Pip distances are converted with the same 3/5-digit pip adjustment used everywhere else in this catalogue; contract size and lot sizing play no part in this harness, since R is a ratio and needs neither. - Up to 300 signals can be pending scoring at once; a very fast cross frequency on a very long InpMaxHoldBars could in principle exceed that and drop the extra signal (logged to the Experts tab if it happens). - The grid does not account for spread or commission - it measures the RAW price path only, which overstates every combination's real edge by roughly the same fixed amount; use it to compare combinations against each other, not to read an absolute expectancy.
Expert advisor · MT4 · v1.0 · Free
About Exit Grid Sweep Harness
Exit Grid Sweep Harness is a script for MetaTrader 4 based on Moving Average. It can alert you with a pop-up, sound, email or push message. It has 12 settings, such as Fast ma period, Slow ma period and Ma method. MQL source code included.
Files in the download: ExitGridSweepHarness.ex4, ExitGridSweepHarness.mq4, ExitGridSweepHarness.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fast ma period | 10 | Fast MA period |
| Slow ma period | 30 | Slow MA period |
| Ma method | MODE_EMA | MA method (0 SMA,1 EMA,2 SMMA,3 LWMA) |
| Stop min pips | 10.0 | Stop-loss grid: minimum |
| Stop max pips | 40.0 | Stop-loss grid: maximum |
| Stop step pips | 10.0 | Stop-loss grid: step |
| Target min pips | 10.0 | Take-profit grid: minimum |
| Target max pips | 60.0 | Take-profit grid: maximum |
| Target step pips | 10.0 | Take-profit grid: step |
| Max hold bars | 48 | Bars allowed to elapse before a combo is scored a timeout |
| Report every n signals | 5 | Write the CSV heatmap after this many newly-scored signals |
| Report file name | ExitGridSweepHarness_report.csv | Report file, written under MQL4\Files\ |
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: Grid · Moving Average · Buy/Sell Arrows · Alerts · MT4 Expert Advisor · MQL4 Source Code