Rank: Newbie
Groups: Registered, Registered Users Joined: 8/2/2005(UTC) Posts: 8
|
The Custom Formulas section of the MetaStock website lists the following under MACD Histogram.
https://www.metastock.com/Customer/Resources/Formulas/?c=&p=&i=&Id=326e0f21]Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),60,E) - Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),130,E) - Mov(Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),60,E) - Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),130,E),45,E)[/code:1:08186e0f21]
This code is not entirely self explanatory to me. I re-wrote it a bit to try and get a handle on it. Here's my version.
[code:1:08186e0f21]WeeklyClose := Peak(1,If(DayOfWeek()=5,C,0),1);
WeeklyMACD :=
Mov(If(DayOfWeek()=5,C,WeeklyClose),60,E) -
Mov(If(DayOfWeek()=5,C,WeeklyClose),130,E);
WeeklyMACD - Mov(WeeklyMACD,45,E)[/code:1:08186e0f21]
I believe I misnamed the variable WeeklyClose and do not entirely understand what the Peak function is trying to do here. First off it seems to me we already know that DayOfWeek() does not equal 5. Because if it does we will not evalauate WeeklyClose in the first place. Rather C will be returned instead. So why is this replicated in the Peak function call?
It seems to me the call to Peak is trying to deal with the boundary condition of the last week in the series which may not include a full week. Is this correct? If so it appears to me that this code mishandles the boundary condition. Shouldn't it just return the Close for today?
I guess the bottom line is I don't understand the theory behind this version of weekly MACD from daily data.
TIA
|