Level Touch Decay Study
The idea that a support or resistance level gets weaker every time it is retested is common trading folklore. This script tests it directly: it grids the chart into evenly spaced levels, walks the loaded history once, and for every fresh touch of a level checks whether price held (rejected back away) or broke through a fixed number of bars later. Each level keeps its own running visit counter, so the SAME touch outcome is also bucketed by which numbered visit it was for that specific level - the 1st time it was tested, the 2nd, the 3rd, and 4th-or-later pooled together. A touch only registers as a new visit when the level was outside the PREVIOUS bar's range - a market grinding sideways across a level for ten bars counts as one long test, not ten separate ones. Without that rule the visit-number buckets would fill with repeats of the same episode rather than genuinely independent tests, and any real decay pattern would be buried under noise. The output is a small table: visit number, sample size, hold percentage, break percentage. A level that behaves the way the folklore claims should show its hold percentage falling as the visit number rises; a level that does not decay will show a roughly flat line across the buckets instead. Notes and limitations - Levels are a fixed grid, not swing points or round numbers specifically - it measures decay for "any price the market keeps returning to at this spacing", not decay for a chosen kind of technical level. - The outcome is judged from the close InpReactionBars bars later, not the extreme price reached in between. - This is a descriptive study, not a trading signal. High visit-number buckets naturally carry smaller samples than the 1st-touch bucket - treat a thin "4+" row with appropriate scepticism. - Grid levels never expire in this script; a level from the very start of the loaded history can still accumulate visits at the very end of it.
Script · MT5 · v1.0 · Free
About Level Touch Decay Study
Level Touch Decay Study is a script for MetaTrader 5. 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: LevelTouchDecayStudy.ex5, LevelTouchDecayStudy.mq5, LevelTouchDecayStudy.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to study, blank = this chart's symbol | |
| Timeframe | PERIOD_H1 | Timeframe to study |
| Max bars | 8000 | Most recent bars to include |
| Level step pips | 30.0 | Spacing between grid levels, in pips |
| Reaction bars | 5 | Bars after the touch checked for the outcome |
| Reaction threshold pips | 8.0 | Move past/away from the level needed to call an outcome |
| Max touch bucket | 4 | Visits at or above this number are pooled into "N+" |
| Save csv | true | Write every touch event to a CSV file |
| Delimiter | DelimiterComma | CSV column separator |
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 · Support & Resistance · Alerts · MT5 Script · MQL5 Source Code