{Function: _T3xStdDev
By Alex Matulich, adapted from T3Average by Bob Fulks; May 2003
This function is an exponential moving standard deviation adaptation
of the T3 moving average described in the 1/1998 issue of TASC,
p57, "Smoothing Techniques for More Accurate Signals." by Tim
Tillson. The function calls _xStdDev (exponential moving standard
deviation), which allows variable lookback lengths.
_T3xStdDev(x,n) returns a smoother version of the standard deviation
with equivalent lag.
}
Inputs: Price(NumericSeries), Length(NumericSimple);
Variables: b(0.5), b2(b*b), b3(b2*b),
e1(Price), e2(Price), e3(Price), e4(Price), e5(Price), e6(Price),
c1(-b3), c2(3*(b2+b3)), c3(-3*(2*b2+b+b3)), c4(1+3*b+b3+3*b2),
N(0), w1(0), w2(0);
N = Length;
if N < 1 then N = 1;
N = 1 + 0.5*(N-1); {makes lag equivalent to Moving Average}
w1 = 2 / (N + 1); w2 = 1 - w1;
value1 = _T3Average(price, Length);
e1 = SquareRoot(w1*(price-value1)*(price-value1) + w2*e1*e1);
value1 = _T3Average(e1, Length);
e2 = SquareRoot(w1*(e1-value1)*(e1-value1) + w2*e2*e2);
value1 = _T3Average(e2, Length);
e3 = SquareRoot(w1*(e2-value1)*(e2-value1) + w2*e3*e3);
value1 = _T3Average(e3, Length);
e4 = SquareRoot(w1*(e3-value1)*(e3-value1) + w2*e4*e4);
value1 = _T3Average(e4, Length);
e5 = SquareRoot(w1*(e4-value1)*(e4-value1) + w2*e5*e5);
value1 = _T3Average(e5, Length);
e6 = SquareRoot(w1*(e5-value1)*(e5-value1) + w2*e6*e6);
_T3xStdDev = squareroot(n)*(c1*e6 + c2*e5 + c3*e4 + c4*e3);