logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
knorthington  
#1 Posted : Monday, May 1, 2006 3:07:42 PM(UTC)
knorthington

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 4/30/2006(UTC)
Posts: 15
Location: North Carolina

I'm trying to write some code that produces a data array value from the same date 1 year ago. Here's what I've written and it's not working. According to tech support what I want is possible, I'm just going about it wrong. Any help would be appreciated. Kirk x:= Fml("Max DLRL Delta 20"); d:= DayOfMonth(); m:= Month(); y:= Year(); x2:=ValueWhen(2,d = DayOfMonth() AND m = Month() AND y = 2005 ,x); x
hayseed  
#2 Posted : Monday, May 1, 2006 4:23:49 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey kirk..... there are several versions of that around.... often times the year ago date might fall on a weekend which could induce some troubles..... depending on just how accurate your figure needs to be, the ref function might work..... such as ; Ref(C,-251); would return the close from roughly a year ago, +/- a day...... below is just shootin from the hip but might get ya close....... some use 252 instead of 251......h
a:=Ref(C,-251); a
so perhaps kirk fml +/- 1 day
x:= Fml("Max DLRL Delta 20"); y:=ref(x,-251); y ------------------------------
Jose  
#3 Posted : Monday, May 1, 2006 4:29:52 PM(UTC)
Jose

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)
Kirk, one of the problems with your code is that today's date a year back, may actually fall on a weekend or holiday. The code below fetches data from a year ago (or next available date), as from today (i.e., measured from the last data bar on the chart): [code:1:72e2ac637e] x:=Fml("Max DLRL Delta 20"); lastDay:=LastValue(DayOfMonth()); lastMonth:=LastValue(Month()); lastYear:=LastValue(Year()); start:=Year()>lastYear-1 OR (Year()=lastYear-1 AND (Month()>lastMonth OR Month()=lastMonth AND DayOfMonth()>=lastDay)); signal:=start AND Alert(start=0,2); ValueWhen(1,signal,x) [/code:1:72e2ac637e] And the Ref() function can approximate a year ago, but runs into problems when data is missing: [code:1:72e2ac637e] x:=Fml("Max DLRL Delta 20"); YearlyPeriods:=252; Ref(x,-YearlyPeriods) [/code:1:72e2ac637e] In order to fetch data correctly based on true calendar days rather than periods, you will need a third-party custom dll, such as the accurate LookBack.dll which I offer to my clients. jose '-)
kanellop  
#4 Posted : Monday, May 1, 2006 4:37:57 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Hello Hayseed! I quiet believe that your Formula with the Ref Function, is not for the Current Case! Suppose that today is 30 April 2006. The Equis knorthington Member, need to calculate, for example, a Formula Price in the exact Day of 30 April 2005. So, the Ref(C, -251) does not guarantee that the Ref(C, -251) will be at 30 April 2005. Maybe will be at 4 May 2005 or 2 May 2005. Only from luck will be at 30 April 2005 with the Ref(C, -251) I think that is Time, for the Help of my Favourite Jose!!! I quiet believe that is matter of Seconds to him, to write that kind of Formula and to Help!!! Kind Regards, George Kanellopoulos.
Jose  
#5 Posted : Monday, May 1, 2006 4:46:20 PM(UTC)
Jose

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)
George, you are too kind with your comments, and you definitely over-estimate my talent. ;) jose '-)
hayseed  
#6 Posted : Monday, May 1, 2006 6:00:01 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey george.... you must not be familar with the term, 'shootin from the hip'...... yes, you are correct in your concerns..... the ref is simply offsetting the chart approx 1 year..... the code below, just for you, should plot a 'flatline' valuewhen line for exact days.... that indicator can be ploted multiple times in the same window, providing of course the day selected was a trading day...... the '[color=red:b4dce17cb4]c[/color]' is variable and can be substituted in multiple choice style with other arrays for interesting insights..... the flat line aspect is useful in several other intraday applications..... h
d:=Input("day",1,31,1); m:=Input("month",1,12,3); y:=Input("year",1990,2010,2006); a:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,[color=red:b4dce17cb4]c[/color]); a
so making some substitutions perhaps.....
d:=Input("day",1,31,1); m:=Input("month",1,12,3); y:=Input("year",1990,2010,2006); a:=Fml("Max DLRL Delta 20"); b:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,a); b
kanellop  
#7 Posted : Monday, May 1, 2006 7:31:51 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Hayseed, I received your Message. First i want to note, that with my opinion, this Topic in one from most valuable in Formulas! I say that because here are written DATE FORMULAS extremaly rare! Hayseed after that Words and Formulas that you written in this Topic, i am in a little Shock! I appreciate your Help in this Topic and also the Help of my Favourite Jose! Kind Regards, George Kanellopoulos.
kanellop  
#8 Posted : Monday, May 1, 2006 9:54:23 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Hayseed, This Hour i test your Formula, d:=Input("day",1,31,1); m:=Input("month",1,12,3); y:=Input("year",1990,2010,2006); a:=Fml("Max DLRL Delta 20"); b:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,a); b Was a Nice Thought. Exist something else that i want to ask. Do you believe that exist Date Formula which can make the following thing: When a Formula occurs in any Day, for example the Formula: Fml("Max DLRL Delta 20"), then from the Day that was born the above Formula until exactly after 3 Months (For Example), to be True or False the following Metastock Formula: (HHV(H, 20)-L)*100/HHV(H, 20) > 15 For example, suppose that the Fml("Max DLRL Delta 20"), occur exactly the 31/10/2005, then, when exist, the (HHV(H, 20)-L)*100/HHV(H, 20) > 15, from 31/10/2005 until exactly 31/01/2006 to be True or otherwise False, so, to receive Price 1 for the True and 0 for the False. Do you believe that can exist a Formula like that? Kind Regards, George Kanellopoulos.
hayseed  
#9 Posted : Monday, May 1, 2006 10:27:23 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey george.... as an example of substituting for the 'c', changing from close to open and also adding ref(c,-1) will enable you to track gaps.... in the case of 5 chart layouts at times the gap will be off the screen, as space is at a premium.... a 'gap tracker' indicator will keep that gap in the field of view.... there are many other such variations......h gap tracker
m:=Input("month",1,12,1); d:=Input("day",1,31,1); y:=Input("year",1990,2010,2006); a:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,Ref(C,-1)); aa:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,O); a;aa
multiple choice
pnt:=Input("close=1, open=2, high=3, low=4",1,4,1); m:=Input("month",1,12,1); d:=Input("day",1,31,1); y:=Input("year",1990,2010,2006); a:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,C); aa:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,O); aaa:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,H); aaaa:=ValueWhen(1, Month()=m AND DayOfMonth()=d AND Year()=y,L); If(pnt=1,a,If(pnt=2,aa,If(pnt=3,aaa,If(pnt=4,aaaa,a)))); --------------------------------
hayseed  
#10 Posted : Monday, May 1, 2006 10:50:02 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey george.... just noticed your question..... i'll have to substitue something for Fml("Max DLRL Delta 20"); cause to tell you the truth i haven't a clue as to what it is..... the use of fml and not extfml leads me to believe is kirks creation..... will give it some thought and holler back later.....h
kanellop  
#11 Posted : Monday, May 1, 2006 10:55:34 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Hayseed, I received your Message and Thank You. I want to note that i do not not to track gaps...! I want to track Conditions(If Exist) that occur in a Specific Date Period and also not Metastock Formula Language Periods meaning 250 Periods, 240 Periods. For that reason i create that Question. Please check it again and if it is possible to you make your Comments, again! Kind Regards, George Kanellopoulos.
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.