|
Corrected Moving average
Have someone can help with this indicator?
I need to have the possibility to draw the sma...or not...
Thanks
Here's Tradestation Code:
{Corrected Average (CA), A.Uhl, Oct. 25, 2005}
vars:
CA(0),SA(0),n(0),
v1(0),v2(0),K(0);
inputs:
Price(Close),length(35);
if CurrentBar=1 then
CA=Price
else
begin
if CurrentBar<length then
n=CurrentBar
else
n=length;
SA=Average(Price,n);
v1=Square(StdDev(Price,n));
v2=Square(CA[1]-SA);
if v2<v1 then
K=0
else
K=1-v1/v2;
CA=CA[1]+K*(SA-CA[1]);
end;
Plot1(CA,"Correct Avg",Red,White,3);
Plot2(SA,"Simple Avg",Blue,White,1);
|