Time To Target Versus Stop Study
Before deciding whether an entry signal is any good, it is worth knowing what a fixed target and stop pair does with NO signal at all - applied to literally every bar in history. This script runs that baseline: at every bar's close it projects a fixed-pip target and a fixed-pip stop, both directions if asked, and scans forward up to a chosen horizon to see which one is reached first. Three outcomes are tracked per trial: target first, stop first, or neither within the horizon - the last one matters, because folding an undecided trial into either "win" or "loss" would misstate the edge in whichever direction fits the story. Expectancy in R-multiples is reported only over the decided trials, using the actual reward-to-risk ratio implied by the two pip inputs. Results are reported in pips and R, never in money. This is a study of one fixed distance pair applied uniformly across history, with no position size attached to it, so a money figure here would only manufacture a false sense of precision - R-multiples are what a fixed target/stop pair's raw edge is actually measured in. When a bar's range touches both the target and the stop in the same forward bar, the trial is scored as the stop - the pessimistic assumption, made because minute-resolution history is rarely available far enough back to know which was actually touched first. That single choice biases every ambiguous bar the same direction, so it does not quietly favour whichever outcome looks better. Notes and limitations - This is a descriptive study of a fixed distance pair, not a strategy backtest - it has no entry signal, no spread, slippage or commission, and every bar in history is treated as a hypothetical entry regardless of whether it would ever actually have been traded. - Ambiguous bars where both the target and the stop are inside the same forward bar's high/low range are scored as the stop - see the full description for why. - The newest InpMaxHorizonBars bars cannot be judged yet (not enough forward data exists) and are automatically excluded from the trial count. - Expectancy is computed only over decided trials; a high "neither" rate means the horizon is too short for the chosen pip distances relative to the timeframe's typical bar range, and the expectancy figure rests on a smaller sample than the headline trial count suggests.
Script · MT4 · v1.0 · Free
About Time To Target Versus Stop Study
Time To Target Versus Stop Study is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Symbol, Timeframe and Max bars. MQL source code included.
Files in the download: TimeToTargetVersusStopStudy.ex4, TimeToTargetVersusStopStudy.mq4, TimeToTargetVersusStopStudy.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to study, blank = this chart's symbol | |
| Timeframe | PERIOD_H1 | Timeframe the entries and targets are measured on |
| Max bars | 2000 | Most recent entry bars to include |
| Direction | DirectionBoth | Which side(s) to study |
| Stop pips | 20.0 | Fixed stop distance, in pips |
| Target pips | 40.0 | Fixed target distance, in pips |
| Max horizon bars | 100 | Bars forward searched before giving up |
| Save csv | true | Write every individual trial to a CSV file |
| Delimiter | DelimiterComma | CSV column separator |
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: Buy/Sell Arrows · Alerts · MT4 Script · MQL4 Source Code