I would like to add a simple channel width calculation to a Regression line indicator.
Indicator and simple picture attached.
Channel width calculation should be added as 4th buffer to the original indicator.
I tried the basic Pythagorean calculation below, but I was nor working correctly. Channel width must be calculated in correct point value (for example in Euro 40 pip channel buffer output is 0.00400)
double angle =(fx[barStart]-fx[barStart+bars])/bars;
double distance =(sqh[barStart]-sql[barStart]);
D2 = MathPow(distance,2);
A2 = MathPow(angle,2);
X2 = D2/(A2+1);
X = MathSqrt(X2);
// X is supposed to be the channel width, but this formula doesn't give correct result