Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 7/31/2007(UTC) Posts: 2
|
Hi,
Looking for some help in writing a % change formula.
What i am wanting to do write a formula which will calculate the % change from last trading date to a specific date in the past. Now I can use REF but as each new trading day is done I have to edit the REF formula by adding 1 to it.
As example if col B is close for last trading day and col C is close for say may 1 2008 then in col D the formula will calculate the % change between the two dates. Col C must remain fixed ie this date is not to change.
TIA
John
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
Hi John,
The formula below was taken from another forum and posted by Preston Umrysh (also a member of this forum posting under the name of pumrysh) however I don't know if he was the original author of the code.[:)]
{Name: ROC since a date}
Day1 := Input("Day", 1,31,4); Month1 := Input("Month" ,1,12,1); Year1 := Input("Year" ,1900,2400, 2008); {default date changed from 1999 to 2008} 100 * (CLOSE - ValueWhen(1, DayOfMonth( ) = Day1 AND Month()=Month1 AND Year() = Year1, CLOSE))/ ValueWhen(1, DayOfMonth( )= Day1 AND Month()=Month1 AND Year()=Year1,CLOSE)
Cheers,
oz
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 7/31/2007(UTC) Posts: 2
|
Hi Oz,
Tks for yr post :)
Brilliant...:) works like a charm.
I guess I can reference this formula in an exploration using "fml"?
Cheers
John
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
Hi John,
I think that if you are going to use the above formula in an exploration you should copy and paste the code into an exploration and hard code the three variables.
For example, if in an exploration you wanted to know the ROC of securities since 30th November 2007 the first three lines of code would be:-
Day1 :=30; Month1 :=11; Year1 :=2007;
Good exploring!
oz
|
|
|
|
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.