Skip to main content

Optimum Moving Averrage for Amibroker (AFL)

Lars almost 15 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    amibroker, moving average

This is a special Moving Average especially for sideway markets!

Indicator / Formula

Copy & Paste Friendly
price = ParamField("field");
n = Param("periods",35);
SA=MA(Price,n);
v1=(StDev(Price,n))^2;

Ca=Null;
Ca[n]=sa[n];

for(i=n+1; i<BarCount;i++){
v2[i]=(CA[i-1]-SA[i])^2;
k[i]=IIf(V2[i]<V1[i],0,1-V1[i]/V2[i]);
CA[i]=CA[i-1]+K[i]*(SA[i-1]-CA[i-1]);
}
Plot(Ca,"OMA("+WriteVal(n,1.0)+")",colorYellow,styleThick);
Col = IIf(BarsSince(Ref(Ca,-1)>Ca)>BarsSince(Ref(Ca,-1)<Ca),colorBrightGreen,colorRed);
Plot(C,"",Col,styleBar);

2 comments

over 14 years ago

Hi, is there by anychance convert this code to Metastock? Tks a lot…

Leave Comment

Please login here to leave a comment.