Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
The following formula plots a percent rate of change between a specific date and today. The user is prompted for the specific date. This will only work in MetaStockTM for Windows 95/NT version 6.5 (or higher) or in MetaStock Professional.
Construct the formula in the Indicator Builder, giving it the name shown below in bold. All the text after "FORMULA:" and before "*END OF FORMULA*" below should be placed in the Formula field in the Indicator Builder. Once the indicator has been created, you can drag it out of the Indicator Quicklist for placement in an inner-window of your chart.
NAME: ROC Since a Date
FORMULA:
Day1 := Input("Day",1,31,4);
Month1 := Input("Month",1,12,1);
Year1 := Input("Year",1900,2400,1999);
100 * (CLOSE - ValueWhen(1,DayOfMonth() = Day1 AND Month() = Month1 AND Year() = Year1, CLOSE))/ ValueWhen(1,DayOfMonth() = Day1 AND Month() = Month1 AND Year() = Year1,CLOSE)
|
|
|
|
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)
|
Patrick, I can see a couple of potential problems with the formula above, both having to do with the date input.
If the date user-input falls on a non-trading day (or if not enough chart data bars are loaded), the indicator will not plot anything.
Also, unless this has changed in v9.1, most MetaStock versions will only process dates between the years 1800~2200. Handy to know for those wacky time-travellers.
To avoid any date-related problems, this is how I would code the ROC-date indicator:
[code:1:26bdb3d340]{ Date inputs }
StDay:=Input("start Day",1,31,1);
StMnth:=Input("start Month",1,12,1);
StYear:=Input("start Year",1800,2200,2005);
{ Selected date signal }
start:=Year()>StYear
OR (Year()=StYear AND (Month()>StMnth
OR Month()=StMnth AND DayOfMonth()>=StDay));
date:=start AND Alert(start=0,2);
{ Plot ROC in own window }
100*(C-ValueWhen(1,date,C))/ValueWhen(1,date,C)
[/code:1:26bdb3d340]
jose '-)
http://metastocktools.com
.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
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.