Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
And here's an updated version of the weekly OHLC, now with more options:
[code:1:4971e188f6]
===========
Weekly OHLC
===========
---8<---------------------------
{ Weekly Open/High/Low/Close v3.0 }
{ For daily/intraday charts }
{ Requires "Week's true start & end" indicator }
{ ©Copyright 2002~2005 Jose Silva
The grant of this license is for personal use
only - no resale or repackaging allowed.
All code remains the property of Jose Silva.
http://www.metastocktools.com }
{ User inputs }
pds:=Input("Week's OHLC: [1]Current, [2]Previous",1,2,1);
EOW:=Input("Final week's end: [1]True, [2]Current (dynamic)",1,2,2);
plot:=Input("plot: [1]Price, [2]Week's start/end signals",1,2,1);
plotOp:=Input("plot weekly Open? [1]Yes, [0]No",0,1,1);
plotHi:=Input("plot weekly High? [1]Yes, [0]No",0,1,1);
plotLo:=Input("plot weekly Low? [1]Yes, [0]No",0,1,1);
{ Week's true Start }
WkStart:=
FmlVar("Week's true start & end","WEEKSTART");
{ Choice of Static/Dynamic last EOW signal }
EOW:=If(EOW=2,Cum(1)=LastValue(Cum(1)),
Cum(1)=LastValue(Cum(1)) AND DayOfWeek()=5);
{ Week's true End (EOW) }
WkEnd:=EOW OR
FmlVar("Week's true start & end","WEEKEND");
{ Week's Open }
wkOp:=ValueWhen(pds,WkStart,O);
wkOp:=ValueWhen(1,wkOp>0,wkOp);
{ Week's High }
Hi:=HighestSince(1,WkStart,H);
wkHi:=If(pds=1,Hi,
ValueWhen(1,WkStart,Ref(Hi,-1)));
wkHi:=ValueWhen(1,wkHi>0,wkHi);
{ Week's Low }
Lo:=LowestSince(1,WkStart,L);
wkLo:=If(pds=1,Lo,
ValueWhen(1,WkStart,Ref(Lo,-1)));
wkLo:=ValueWhen(1,wkLo>0,wkLo);
{ Week's Close }
wkCl:=ValueWhen(pds,WkEnd,C);
wkCl:=ValueWhen(1,wkCl>0,wkCl);
{ Select price plots }
wkOp:=If(plotOp,wkOp,wkCl);
wkHi:=If(plotHi,wkHi,wkCl);
wkLo:=If(plotLo,wkLo,wkCl);
wkOp:=If(plot=1,wkOp,WkStart);
wkHi:=If(plot=1,wkHi,-WkEnd);
wkLo:=If(plot=1,wkLo,WkStart);
wkCl:=If(plot=1,wkCl,-WkEnd);
{ Plot price on chart, signals in own window }
wkOp; { Open: Violet}
wkHi; { High: Blue }
wkLo; { Low: Red }
wkCl; { Close: Green }
---8<---------------------------
[/code:1:4971e188f6]
jose '-)
http://www.metastocktools.com
.
|