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)
|
This MS indicator plots the High & Low signals for each year, and their corresponding dates in ddmmyy format.
[code:1:f63dd155bd]
MetaStock -> Tools -> Indicator Builder -> New ->
Copy and paste complete formula between "---8<---" lines.
==================
Year's Hi/Lo dates
==================
---8<-----------------------------
{ Year's High & Low dd/mm/yy dates v1.0
©Copyright 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 input }
plot:=Input("plot: [1]Hi/Lo signals, [2]dd/mm/yy dates",1,2,1);
{ Start of year }
init:=Cum(1)=2;
nuYear:=Year()<>Ref(Year(),-1) OR init;
{ High signals of year }
YearHi:=H=HighestSince(1,nuYear,H);
{ Last High of current year signal }
event:=YearHi;
{ dd/mm/yy of last High of year's signal }
y:=ValueWhen(1,event,Year());
y:=If(y<2000,y-1900,y-2000);
m:=ValueWhen(1,event,Month())*100;
d:=ValueWhen(1,event,DayOfMonth())*10000;
dateHi:=y+m+d;
{ Low signals of year }
YearLo:=L=LowestSince(1,nuYear,L);
{ Last Low of current year signal }
event:=YearLo;
{ dd/mm/yy of last Low of year's signal }
y:=ValueWhen(1,event,Year());
y:=If(y<2000,y-1900,y-2000);
m:=ValueWhen(1,event,Month())*100;
d:=ValueWhen(1,event,DayOfMonth())*10000;
dateLo:=y+m+d;
{ Plot in own window }
If(plot=1,YearHi,dateHi);
If(plot=1,-YearLo,-dateLo)
---8<-----------------------------
[/code:1:f63dd155bd]
jose '-)
|