Moving Averages for Amibroker (AFL)
kelvinhand over 13 years ago Amibroker (AFL)
Mimic the idea from MT Platform. Allow the user to instantly change the Method, Period, Price, Shift to judge which MA. to use
Required Drag n Drop into price chart.
Indicator / Formula
Copy & Paste Friendly
//-- Author: KelvinHand
//TP - Typical Price (H+L+C)/2
//MP - Median Price (H+L)/2
//WP - Weight Price (H+L+C+C)/4
MAType = ParamList("Type", "SMA,EMA,WMA,TSF,DEMA,TEMA,LinearReg,Wilders");
Periods = Param("Periods", 20, 1, 500 );
iPrice = ParamList("Price", "C,O,H,L,MP,TP,WP");
Shift = Param("Shift", 0, -50, 50 );
cColor = ParamColor("Color", ColorCycle);
iStyle = ParamStyle("Style", styleLine, maskAll);
switch (iPrice)
{
case "O" : p = Open; break;
case "H" : p = High; break;
case "L" : p = Low; break;
case "MP" : p = (H+L)/2; break;
case "TP" : p = (H+L+C)/3; break;
case "WP" : p = (H+L+C+C)/4; break;
default: p = Close; break;
}
switch (MAType)
{
case "EMA": iMA = EMA( P, Periods ); break;
case "WMA": iMA = WMA( P, Periods ); break;
case "DEMA": iMA = DEMA( P, Periods ); break;
case "TEMA": iMA = TEMA( P, Periods ); break;
case "Wilders": iMA = Wilders( P, Periods ); break;
case "TSF": iMA = TSF( P, Periods ); break;
case "LinearReg": iMA = LinearReg( P, Periods ); break;
default: iMA = MA( P, Periods ); break;
}
ShortName = MAType+Periods+iPrice;
if (Shift !=0)
ShortName = ShortName + "x"+Shift;
Plot( iMA, ShortName, cColor, iStyle, 0, 0, Shift);1 comments
Leave Comment
Please login here to leave a comment.
Just need to go in parameter n change it..good invention. Thanx you