Channel Third Touch Reliability Study
"A trendline gets weaker with every touch" is a widely repeated piece of chart-reading folklore that almost never gets tested against an actual defined channel. This script tests it: it fits a linear-regression channel to a rolling window of closes, checks whether the fit is tight enough to call a genuine channel rather than noise, then projects the same line and width forward in time and tracks every boundary touch in sequence - numbering them 1st, 2nd, 3rd, 4th-or-later - recording whether price held (pulled back) or broke (closed through) at each one. Channel validity is judged by comparing the fitted band's width against ATR, not by how many of the fit window's own points sit inside the band. Containment computed from residuals that generated the band's own width is close to circular - a band wide enough as a multiple of its own standard deviation will always "contain" most of the data it was fitted to, regardless of whether the market actually behaved like a channel. A band that is tight relative to ATR is the genuine signal that the window was channel-like rather than merely close to a straight line by chance. Every touch is re-evaluated against the regression line's own ongoing projection, not a fixed level, since the whole point of a channel is that its boundaries move. A touch is scored a hold if price later closes back inside by a margin without ever closing through the band by the break buffer first, a break if the reverse happens first, or undecided if neither resolves within the lookahead. A close far enough beyond either band abandons the channel outright - at that point the fitted line has stopped describing the market, and counting further touches against it would be meaningless. Notes and limitations - This is a descriptive study, not a trading signal. A hold-rate difference between touch numbers on a small sample is not evidence of anything; check the reach (sample count) column for each touch number before drawing conclusions. - The channel is a straight-line least-squares fit with a fixed width, not a trader's hand-drawn trendline - it will not match every channel a discretionary chart reader would draw, particularly on data with a genuine curve to it. - The residual standard deviation, and therefore the band width, is held constant from the original fit window as the line is projected forward; only the centre line's position moves with the slope. A market that becomes meaningfully more or less volatile after the fit window will make the projected band too narrow or too wide for that later behaviour. - A single bar whose high touches the upper band and whose low touches the lower band in the same bar is skipped as an ambiguous touch rather than counted for either side. - Overlapping or nested channels are not considered - the scan moves on to the next window only after the current channel is fully resolved or times out, so only one channel is ever being tracked at a time.
Script · MT4 · v1.0 · Free
About Channel Third Touch Reliability Study
Channel Third Touch Reliability Study is a script for MetaTrader 4 based on ATR. It can alert you with a pop-up, sound, email or push message. It has 15 settings, such as Symbol, Timeframe and Max bars. MQL source code included.
Files in the download: ChannelThirdTouchStudy.mq4, ChannelThirdTouchStudy.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to study, blank = this chart's symbol | |
| Timeframe | PERIOD_H1 | Timeframe to study |
| Max bars | 5000 | Most recent bars to include |
| Channel window bars | 40 | Bars used to fit each regression channel |
| Channel width mult | 2.0 | Band half-width in residual standard deviations |
| Atr period | 14 | ATR period used to judge whether a fit is tight enough |
| Max width atr mult | 3.0 | Fitted band width (top to bottom) must be at most this multiple of ATR |
| Touch tolerance pips | 3.0 | High/low within this many pips of a band counts as a touch |
| Hold pips | 8.0 | Pullback away from the band needed to call a touch a hold |
| Break buffer pips | 3.0 | Close beyond the band by this many pips counts as a break |
| Hold lookahead bars | 15 | Bars checked forward to decide hold vs break per touch |
| Max forward bars | 150 | Bars projected forward before a channel is abandoned unresolved |
| Invalidate atr mult | 2.5 | Close this many ATRs beyond the band abandons the channel entirely |
| 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 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: Channels & Envelopes · Trend · Alerts · ATR · MT4 Script · MQL4 Source Code