返回代码库
TradingView指标未分类已发布

Alpha Regression Channel R2 [identityKa]

TradingView 原文 · 抓取于 2026.09.30

TradingView 指标 · IdentityKa

原作者IdentityKa
首次发布2026.10.05
当前版本v1.0
已审核发布文件tradingview-wgvmnfcg.pine14.0 KB · TradingView · v1.0
SHA-256
ba58c146f33a6b54d2485f2061dedd09e84b8c959ae1a193cdbf36a4c3d572cd
授权
待确认
授权与文件校验
授权条款
待确认
SHA-256
ba58c146f33a6b54d2485f2061dedd09e84b8c959ae1a193cdbf36a4c3d572cd
登录后下载;未登录仍可查看源码预览
SOURCE PREVIEW

源码预览

正在读取已发布源码…
CAPABILITIES

核心功能

Alpha Regression Channel R2 [identityKa]

Not just "which way is the trend" but "how clean is it".

A regression channel draws the best-fit straight line through recent prices. The slope tells you direction. But the real question for any trend approach is how well price actually follows that line. This tool answers it with R² and shows the answer for three horizons at once.

HOW IT WORKS

1. Linear regression line: the least-squares straight line through the last N closes (default 100 bars). 2. R² (coefficient of determination): the share of price variation explained by that straight line, from 0 to 1. Close to 1 means price hugs the line, a clean trend. Close to 0 means the straight line explains almost nothing, price is wandering. 3. Channel width: the bands sit a chosen number of standard deviations of the residuals (the distance of price from the line) above and below the line. Residual standard deviation is computed directly as price standard deviation x square root of (1 - R²), so the channel automatically gets tighter when the trend is clean and wider when it is not. 4. Price position in sigma: where the current close sits relative to the line, in residual standard deviations. Beyond the band edge (default 2 sigma) is marked Above or Below Channel. 5. Trend quality labels: Clean at or above 0.70, Weak at or below 0.40, Moderate in between (adjustable).

Horizon comparison: R² and direction are also computed on two other lengths (default 50 and 200 bars). The dashboard shows which horizon is currently the cleanest, so you can see at a glance which time scale the market is actually trending on.

WHAT YOU SEE

- A regression channel drawn over the last N bars, dashed centre line, colored by direction, grey when the trend is weak - Optional rolling version of the line and bands for every bar - Dashboard: Trend Direction, Trend Quality (R²), Slope in ATR per bar and percent per bar, Channel Width as a percent of price, Price Position in sigma, an R² table for the three horizons, and the Cleanest Horizon

HOW TO USE IT

- Read R² before trusting a slope. A steep slope with low R² is a noisy move. A gentle slope with high R² is an orderly one. - Compare horizons. If the short horizon is Clean but the long one is Weak, the market is trending only on a short scale. - Use price position as a stretch gauge. Price beyond the channel edge means it is far from its fitted line relative to typical noise. What that means depends on trend quality: in a Clean trend it can signal strength, in a Weak one it can signal an extension. - The tool describes conditions, it does not tell you when to act.

SETTINGS

- Calculation: channel length, two comparison horizons, channel width in standard deviations, ATR length - Quality Rules: R² levels for Clean and Weak, flat-slope threshold - Display: colors, channel, fill, extend to the right, rolling version - Dashboard: position, text size, footer

ALERTS

Trend quality became Clean, trend quality became Weak, slope turned Up, slope turned Down, price crossed above the channel, price crossed below the channel. For stable, non-repainting triggers, set the alert to Once Per Bar Close.

NOTES AND LIMITATIONS

- A regression line is fitted to past prices, so the drawn channel changes as new bars arrive. It describes the window, it does not forecast. - Regression assumes a straight-line relationship. Curved or stair-step moves can show a lower R² even when they are orderly. - Channel length is capped at 400 bars for chart drawing limits.

This script is for educational and informational purposes only and is not financial advice. Past behavior does not guarantee future results.

Part of the Alpha Quant Toolkit by identityKa. See also: Alpha Regime Dashboard [identityKa], Alpha MTF Trend Matrix [identityKa].

INSTALLATION

安装与验证

◇
安装说明待补充

在文档完善前,请勿将未验证文件用于实盘环境。