Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
lcl
The indicator I posted was modified from what you are now asking for. Rather than modify it again, here's the formula it came from. It could be simplified somewhat, and removing the requirement for Jose's "Calendar Week counter" is one way to do that. However that would leave the indicator vulnerable to missing data of more than 3 bars. The Calendar Week counter is essential for ensuring the integrity of all weekly frames when missing data is a possibility.
Weekly OHLC has 3 modes. Static plots the weekly OHLC on the Friday or last bar of the week, dynamic updates the current week on each bar, and delayed only plots new values on the first bar of a new week. When backtesting it should generally be used in delayed mode.
As with most of my weekly indicators, this plots on weekly charts as well as EOD charts. That feature is useful for checking values when other functions are based on these weekly prices.
{Weekly OHLC}
{© 2005 Roy Larsen, rlarsen@man.quik.co.nz}
{Use with Jose Silva's "Calendar Week counter"
on EOD charts}
{User settings}
Q:=Input("Weekly OHLC Mode, 0=Static 1=Dynamic 2=Delayed",0,2,0);
{0, update at last bar of current frame}
{1, update on each new bar}
{2, update on first bar of new frame}
{Timing module for weekly frames}
{Set I=0 for Monday to Thursday end-of-week}
I:=Fml("Calendar Week counter");
A:=DayOfWeek();
G:=LastValue(Highest(Sum(A=5,5))=5);
I:=I-ValueWhen(2-G,1,I);
M:=G OR I>0;
F:=G OR (M=0 AND PeakBars(1,Zig(A,1,$),1)=0);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=ValueWhen(2,1,A);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Prices for weekly frames}
Ow:=ValueWhen(1,M,O);
Ow:=ValueWhen(1,J,If(J=1,Ow,ValueWhen(2-G,1,Ow)));
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2-G,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2-G,1,Lw)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Ow:=ValueWhen(1,Ow>0,Ow);
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
{Plot results}
Ow; Hw; Lw; K; {Weekly OHLC}
Roy
MetaStock Tips & Tools
|