A Function that returns a channel using (X,Y) vector points.
_X: Array containing x data points.¹
_Y: Array containing y data points.¹
¹: _X and _Y size must match.
_predictions: Array with adjusted _Y values at _X.
_max_dev: Max deviation from the mean.
_min_dev: Min deviation from the mean.
_stdev/_sizeX: Average deviation from the mean.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.
Just wanted to note, that there are some arrays that don't necessarily start with index 0 (some have values starting at index 2 for example). So when using this function on those arrays, one gets NaN for the outputs. Adding nz() to the arrays in the calculations helps resolve that problem:
_sumXY := _sumXY + (nz(_Xi) * nz(_Yi))
_sumX2 := _sumX2 + pow(nz(_Xi), 2)
_sumY2 := _sumY2 + pow(nz(_Yi), 2)
Very helpful script.