Loading…

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 · MT4 · v1.0 · Free

About Level Touch Decay Study

Level Touch Decay 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: LevelTouchDecayStudy.mq4, LevelTouchDecayStudy.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to study, blank = this chart's symbol
TimeframePERIOD_H1Timeframe to study
Max bars8000Most recent bars to include
Level step pips30.0Spacing between grid levels, in pips
Reaction bars5Bars after the touch checked for the outcome
Reaction threshold pips8.0Move past/away from the level needed to call an outcome
Max touch bucket4Visits at or above this number are pooled into "N+"
Save csvtrueWrite every touch event to a CSV file
DelimiterDelimiterCommaCSV column separator

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Grid · Support & Resistance · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria