Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
This code is a little old.... I've had it for a while and never used it so, use with caution Code:
{Fractal Adaptive Moving Average (FAMA)}
prd:=Input("Periods",1,20,5);
y2:=2*prd;
n1:=(HHV(H,y)-LLV(L,y))/y;
n2:=Ref((HHV(H,y)-LLV(L,y))/y,-y);
n3:=(HHV(H,y2)-LLV(L,y2))/y2;
x:=(Log(n1+n2)-Log(n3))/Log(2);
xt:=Exp(-4.6*(x-1));
x1:=If(xt<0.1,0.1,If(xt>1,1,xt));
x2:=1-x1;
FAMA:=If(Cum(1)=y2,(MP()*x1)+(Ref(MP(),-1)*x2),(MP()*x1)+(PREV*x2));
{plot}FAMA;
All you have to do now is add and subtract a width (constant value, percentage value, standard deviation, volatility, whatever) to form a channel e.g. Code:code as above ...{plot}
FAMA;FAMA + (2 * Stdev(C,prd));
FAMA - (2 * Stdev(C,prd));
Hope this helps. You could always use Google? wabbit [:D] NOTE: Code is untested and may contain errors, bugs, or dead hamsters! P.S. If you want to get rid of the PREV, notice (MP()*x1)+(PREV*x2)) where
x2:=1-x1 is just a EMA? Its late here and I a need sleep...
|