Plot Monthly Weekly And Daily Moving Average

Plot Monthly Weekly And Daily Moving Average
Plot Monthly Weekly And Daily Moving Average
//www.aflcode.com

MaxGraph=7;

//Input Time periods for Monthly,Weekly and Daily Moving Averages
MonthlyPds=10;//Months
WeeklyPds=20;//Weeks
DailyPds=10;//Days 
/***********************************/
//Input Price Variable ( open, high ,low, close);
Price=C;

MonthlyPrice=Price;
WeeklyPrice=Price;
DailyPrice=Price;
/**********************************/

/***Colors***/
//Set to your Preference
Color=6;//Price chart
MthAvgColor=3;//Monthly AverageLine
WklyAvgColor=5;//weekly AverageLine
DlyAvgColor=4;//Daily AverageLine
/**********************************/

Weekly=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1),WeeklyPrice);
Monthly=ValueWhen(Day() > Ref( Day(), 1 ),MonthlyPrice);

MonthlyAvg=EMA(Monthly,MonthlyPds);
WeeklyAvg=EMA(Weekly,WeeklyPds);
DailyAvg=EMA(DailyPrice,DailyPds);

Graph0=C;
Graph0Style=64;
Graph0Color=Color;

Graph1=WeeklyAvg;
Graph1Style=1+4;//Thick line
Graph1Color=WklyAvgColor;

Graph2=DailyAvg;
Graph2Style=1;
Graph2Color=DlyAvgColor;

Graph3=MonthlyAvg;
Graph3Style=1;
Graph3Color=MthAvgColor;


Title=Name()+"  "+"("+WriteVal(WeeklyPds,1)+")"+" Week Moving Average= "+"("+WriteVal(WeeklyAvg,1.2)+")"+" :: "+"("+WriteVal(DailyPds,1)+")"+" Period Moving Average= "+"("+WriteVal(DailyAvg,1.2)+")"+" :: "+"("+WriteVal(MonthlyPds,1)+")"+" Month Moving Average= "+"("+WriteVal(MonthlyAvg,1.2)+")";
Previous
Next Post »