Linear Regression Channel - Touch Statistics [Dots3Red]

194
📐 LINEAR REGRESSION CHANNEL - TOUCH STATISTICS [Dots3Red]
This indicator draws a linear regression channel and measures how often price returned to the regression line after touching the upper or lower channel line on the current chart, split by whether the channel was rising or falling at the time, shown as percentages with the sample size next to them.

✨ WHY THIS MATTERS
The linear regression channel is a classic tool: a best-fit line through recent prices with bands a set number of standard deviations above and below. Traders often fade touches of the outer lines and expect a return to the middle. But a touch of the upper line in a rising channel is a very different situation from the same touch in a falling channel, and how often either one reverts depends on the instrument. This script keeps separate scoreboards for each case.

⚙️ HOW IT WORKS
📐 The channel — a least-squares regression line through the last N bars, with upper and lower lines placed a set number of standard deviations of the residuals away from it. The current channel is drawn across the lookback window and can be extended to the right.
📈 Rolling channel history — on every past bar, the script uses the channel as it stood on that bar, using only data available at the time. You can plot these rolling edges to see exactly what each touch was measured against.
🎯 Touch grading, split four ways — every first touch of a channel line is graded against levels fixed at that moment:
• Reverted — price returns to the regression line
• Failed — price pushes a set number of standard deviations beyond the touched line first, or the window runs out
Touches are tracked separately for upper and lower lines, in rising and falling channels. If both happen on the same bar, it counts as failed.
📏 Trend quality — the dashboard shows the correlation (r) between price and time over the channel length. Values near +1 or −1 mean price has followed a straight line closely; values near 0 mean the channel is a loose fit.
🔒 Non-repainting grading — touches are registered and graded on confirmed bars only, against the channel as it stood on that bar. The drawn current channel updates with each new bar, as any regression channel does.
🖥️ Dashboard — graded touches and reversion rate for each of the four cases, channel direction and r, and price's current distance from the line in standard deviations.

🧭 HOW TO USE
1️⃣ Compare with-trend and against-trend touches. In many markets, a lower-line touch in a rising channel reverts far more often than an upper-line touch in the same channel.
2️⃣ Check r before trusting the channel. A channel with r near 0 is not describing a trend, so its lines carry less meaning.
3️⃣ Match the length to your holding period. Short lengths follow price closely and produce many touches; long lengths describe the bigger trend.
4️⃣ Let each case build a sample. The dashboard shows the count next to every rate.
5️⃣ Use it as context, not a trigger. The rates describe how channel touches have behaved on this chart. They do not predict the next touch.

⏱️ WHICH TIMEFRAMES WORK BEST
Works on any timeframe. 15-minute through daily with a length of 50–150 bars is a good starting point.

🛠️ SETTINGS
📐 Regression Channel — length, source, channel width (× σ)
🎯 Touch Grading — failure distance beyond the band (× σ), max bars to resolve, minimum touches to show a rate
🎨 Visuals — current channel, extend right, channel fill and transparency, rolling bands, line colors and thickness, touch labels and their colors
🖥️ Dashboard — show/hide, position
🔔 Alerts — upper line touch, lower line touch

📝 NOTES
All rates are specific to this chart, timeframe and settings, and do not transfer to other instruments or configurations.

⚠️ DISCLAIMER
This is an analytical and visualization tool. It does not generate trade signals and does not constitute financial advice. Historical statistics do not guarantee future performance.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.