logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Flexi  
#1 Posted : Monday, December 17, 2007 10:24:12 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

Wanted to create an indicator which calculate a 10 days average of the MACD() on monday. For example, today is monday and the indicator would plot the 10 days average of the MACD() value on the previous 10 mondays.

Tried the following but result plot continue to other day (Should remain zero for other days) (Plot on monday)

MD:=if(Dayofweek()=1,MACD(),0);
Mov(MD,10,S)

pumrysh  
#2 Posted : Tuesday, December 18, 2007 11:25:22 AM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

Flexi,

Try this:

MD:=Mov(MACD(),10,S);
if(Dayofweek()=1,MD,0);

Hope this helps,

Preston

Flexi  
#3 Posted : Wednesday, December 19, 2007 12:59:24 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

Hi Preston,

The code does not give what is intended. The idea is taking the MACD() values on only 10 previous monday and divided by 10. Only MACD() values on moday are considered and averaged. Plot this average on the monday.

The code average MACD() average all values from monday to friday which is not intended.

pumrysh  
#4 Posted : Wednesday, December 19, 2007 4:33:04 PM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

Flexi,

Your request was "Wanted to create an indicator which calculate a 10 days average of the MACD() on monday. For example, today is monday and the indicator would plot the 10 days average of the MACD() value on the previous 10 mondays. "

Normally, a MACD is calculated by subtracting a 26 EMA from a 12 EMA. A Weekly MACD uses the close of the week which in most cases would be a Friday.

There are a number of excellent sources for a weekly MACD but I am afraid that they will likely use the Friday close. You will need to make that adjustment. The best sources that I know of would be either Roy's or Jose's sites. They can be found here:

http://www.metastocktips.co.nz/other_formulas.html

http://www.metastocktools.com/#metastock

Trades online offers one but it is probably not what you want. Here is the link anyway:

http://trader.online.pl/MSZ/e-w-MACD_Histogram.html

Hope this helps,

Preston

Flexi  
#5 Posted : Thursday, December 20, 2007 7:44:17 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

Hi Preston,

I am not coding weekly MACD but just want to plot the average of MACD on 10 previous monday. Only monday values are added and divided for the average. The value calculated will be plotted on moday and not other day

pumrysh  
#6 Posted : Thursday, December 20, 2007 9:10:21 AM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

This what you had in mind?

MMD:= ValueWhen(1,DayOfWeek()=1,MACD());
MAMD:=Mov(mmd,10,S);
If(DayOfWeek()=1,MAMD,0);

Preston

Flexi  
#7 Posted : Saturday, December 22, 2007 10:24:00 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

Hi Preston,

MMD:= ValueWhen(1,DayOfWeek()=1,MACD());
MAMD:=Mov(mmd,10,S);
If(DayOfWeek()=1,MAMD,0);

The second code does not average the monday Macd(). Trying to create something:

MMD:= ValueWhen(1,DayOfWeek()=1,MACD());
MMD1:= ValueWhen(2,DayOfWeek()=1,MACD());
MMD2:= ValueWhen(3,DayOfWeek()=1,MACD());

If(DayOfWeek()=1,MAMD + MMD1 + MMD2,0);

The problem with using valuewhen is require to define each previous value and for a average of 20 there are 20 definition MMD. Is there a good way to code this?

Regards.

pumrysh  
#8 Posted : Monday, December 24, 2007 3:19:57 AM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

Flexi,

MAMD:=Mov(mmd,10,S);

and

MAMD:=Sum(mmd,10)/10;

would be the same. If you prefer 20 you would simply change the periods.

Preston

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.