[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Daily and Weekly views



PureBytes Links

Trading Reference Links

Hello,

In the AFL library , there is a formula which you can plot Monthly ,
Weekly and daily Moving averages while staying in Daily mode, No need to
switch modes. It is located at:
http://www.amibroker.com/library/formula.php?id=168

Here is that code modified to show 3 weekly moving averages only, So in
the preference window set your daily moving averages, which show up on
the Main price chart, Then in this code set your weekly averages and
click apply, Now you will have Daily averages on the Main Chart and
Weekly averages in the custom chart, all on the same window tab.

//Plot Weekly Moving Averages on Daily Price Chart
//Coded by Anthony Faragasso

MaxGraph=12;

//Input Time periods for Weekly Moving Averages
WeeklyPds1=20;//Weeks
WeeklyPds2=30;//Weeks
WeeklyPds3=40;//Weeks
/***********************************/
//Input Price Variable ( open, high ,low, close);
Price=C;


WeeklyPrice=Price;

/**********************************/

/***Colors***/
//Set to your Preference
Color=6;//Price chart
WklyAvg1Color=3;//weekly1 AverageLine
WklyAvg2Color=5;//weekly2 AverageLine
WklyAvg3Color=4;//weekly3 AverageLine
/**********************************/

Weekly1=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1),WeeklyPrice);
Weekly2=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1),WeeklyPrice);
Weekly3=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1),WeeklyPrice);



Weekly1Avg=EMA(Weekly1,WeeklyPds1);
Weekly2Avg=EMA(Weekly2,WeeklyPds2);
Weekly3Avg=EMA(Weekly3,WeeklyPds3);

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

Graph1=Weekly1Avg;
Graph1Style=1+4;//Thick line
Graph1Color=WklyAvg1Color;

Graph2=Weekly2Avg;
Graph2Style=1;
Graph2Color=WklyAvg2Color;

Graph3=Weekly3Avg;
Graph3Style=1;
Graph3Color=WklyAvg3Color;


Title=Name()+" "+"("+WriteVal(WeeklyPds1,1)+")"+" Week Moving Average=
"+"("+WriteVal(Weekly1Avg,1.2)+")"+" ::
"+"("+WriteVal(WeeklyPds2,1)+")"+" Week Moving Average=
"+"("+WriteVal(Weekly2Avg,1.2)+")"+" ::
"+"("+WriteVal(WeeklyPds3,1)+")"+" Week Moving Average=
"+"("+WriteVal(Weekly3Avg,1.2)+")";


Watch out for Word Wrap when copy and paste into indicator builder.

Hope this help.
Anthony

miked33 wrote:

> Is there a way that you can set the default preferences for the daily
>
> view to for instance 13,50,200 day MA and the weekly to 20,30,40 week
> MA and then quickly toggle from daily to weekly view? Currently I
> reset the preferences each time I toggle between daily and weekly
> views.
>
> thanks
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.