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

Notification

Icon
Error

Options
Go to last post Go to first unread
wabbit  
#1 Posted : 19 years ago
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Patrick, An edit of the ForumDll.dll file for the DateRange function: //*********************************START DATE RANGE FUNCTION*************************************** BOOL __stdcall DateRange ( const MSXDataRec *a_psDataRec, const MSXDataInfoRecArgsArray *a_psDataInfoArgs, const MSXNumericArgsArray *a_psNumericArgs, const MSXStringArgsArray *a_psStringArgs, const MSXCustomArgsArray *a_psCustomArgs, MSXResultRec *a_psResultRec) { BOOL l_bRtrn = MSX_SUCCESS; int i=0; int MaxRecords = a_psDataRec->sClose.iLastValid; MSXDateTime *psDate = a_psDataRec->psDate; int IntDate = 0; const MSXDataInfoRec *l_StartDate; l_StartDate = a_psDataInfoArgs->psDataInfoRecs[0]; const MSXDataInfoRec *l_EndDate; l_EndDate = a_psDataInfoArgs->psDataInfoRecs[1]; for(i=0; i<=MaxRecords; i++) { IntDate = psDate.lDate; // set the default return as FALSE a_psResultRec->psResultArray->pfValue=0; if(l_StartDate->pfValue==0) { if(IntDate <= l_EndDate->pfValue) {a_psResultRec->psResultArray->pfValue= 1;} } else if(l_EndDate->pfValue==0) { if(IntDate >= l_StartDate->pfValue) {a_psResultRec->psResultArray->pfValue= 1;} } else if(IntDate >= l_StartDate->pfValue && IntDate <= l_EndDate->pfValue) {a_psResultRec->psResultArray->pfValue= 1;} } // only for serious errors... if (l_bRtrn != MSX_SUCCESS) { a_psResultRec->psResultArray->iFirstValid = 0; a_psResultRec->psResultArray->iLastValid = -1; } return l_bRtrn; } //*********************************END DATE RANGE FUNCTION****************************************** allows the user to enter: ExtFml("ForumDll.DateRange", 20050101,0) for dates after the specified date, without specifying an end date i.e "date is after ..." ExtFml("ForumDll.DateRange", 0,20050101) for dates before the specified end date, without specifying a start date i.e. "date is before ..." ExtFml("ForumDll.DateRange", 20050101,20051231) for the standard, between dates. Also, I have used > = and < = to make the dates inclusive... I hope I have done this correctly. I compiled it on my machine and it works correctly. I hope others find this useful too. wabbit :D
Patrick  
#2 Posted : 19 years ago
Patrick

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)
Looks good ... I added your code to the dll and it works 8:-) . I will upload the new version later :D Patrick :mrgreen:
kanellop  
#3 Posted : 19 years ago
kanellop

Rank: Advanced Member

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

Wabbit, Hello. I want to ask you something for your Formula. This Code that you written this Formula is only Metastock Formula Language or you use also another Formula Language? If Yes, which is that Language? George K.
Patrick  
#4 Posted : 19 years ago
Patrick

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)
Kanellop this is written in C++ ... Patrick :mrgreen:
kanellop  
#5 Posted : 19 years ago
kanellop

Rank: Advanced Member

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

Dear Wabbit, Can you create this Formula with Metastock Formula Language only? I do not know C++ Language , and it is a little difficult for me, to follow the Expressions of C++ Language. I am very sorry for that. George K.
Patrick  
#6 Posted : 19 years ago
Patrick

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)
This is the date range function in the dll ... we have already talked about it .. look at the ForumDll manual ... It is the same thing except this is the source code of the dll ... Once again look at the forumdll manual and look at the daterange function. Patrick :mrgreen:
Jose  
#7 Posted : 19 years ago
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)
kanellop wrote:
Can you create this Formula with Metastock Formula Language only?
Try this MS code from http://www.metastocktools.com/#metastock : [code:1:626eb7e459]MetaStock -> Tools -> Indicator Builder -> New Copy and paste formulae below. =========== Date filter =========== ---8<--------------------------- { Date filter } { Plots +1 signal within user-input date period } { http://www.metastocktools.com } StDay:=Input("start Day",1,31,1); StMnth:=Input("start Month",1,12,1); StYear:=Input("start Year",1800,2200,2003); EnDay:=Input("end Day",1,31,31); EnMnth:=Input("end Month",1,12,12); EnYear:=Input("end Year",1800,2200,2003); start:=Year()>StYear OR (Year()=StYear AND (Month()>StMnth OR Month()=StMnth AND DayOfMonth()>=StDay)); end:=Year()<EnYear OR (Year()=EnYear AND (Month()<EnMnth OR Month()=EnMnth AND DayOfMonth()<=EnDay)); start AND (end OR (start AND Alert(start=0,2))) ---8<--------------------------- ============================== Date filter sample application ============================== ---8<--------------------------- { Open/Hi/Lo/Close of specified date period } { http://www.metastocktools.com } { Date inputs } StDay:=Input("start Day",1,31,1); StMnth:=Input("start Month",1,12,12); StYear:=Input("start Year",1800,2200,2004); EnDay:=Input("end Day",1,31,31); EnMnth:=Input("end Month",1,12,12); EnYear:=Input("end Year",1800,2200,2004); { Selected date period } start:=Year()>StYear OR (Year()=StYear AND (Month()>StMnth OR Month()=StMnth AND DayOfMonth()>=StDay)); end:=Year()<EnYear OR (Year()=EnYear AND (Month()<EnMnth OR Month()=EnMnth AND DayOfMonth()<=EnDay)); date:= start AND (end OR (start AND Alert(start=0,2))); { Open/Hi/Lo/Close for date period } Op:=ValueWhen(1,date=1 AND Alert(date=0,2),O); Hi:=Highest(ValueWhen(1,date,H)); Lo:=Lowest(ValueWhen(1,date,L)); Cl:=ValueWhen(1, date=0 AND Alert(date,2),Ref(C,-1)); { Plot on price chart } Op; { Black } Hi; { Red } Lo; { Blue } Cl; { Green } ---8<--------------------------- ============ Date signals ============ ---8<--------------------------- {Date signals} {Plots +1/-1 signals on user-input dates} {http://www.metastocktools.com} StDay:=Input("start Day",1,31,1); StMnth:=Input("start Month",1,12,1); StYear:=Input("start Year",1800,2200,2003); EnDay:=Input("end Day",1,31,31); EnMnth:=Input("end Month",1,12,12); EnYear:=Input("end Year",1800,2200,2003); today:=Year()+Month()/12+DayOfMonth()/373; stInput:=StYear+StMnth/12+StDay/373; endInput:=EnYear+EnMnth/12+EnDay/373; start:=stInput>Ref(today,-1) AND stInput<=today; end:=endInput>Ref(today,-1) AND endInput<=today; signals:=If(start=end,start,start-end); signals ---8<--------------------------- =========== Time filter =========== ---8<--------------------------- {Intraday time filter} {Plots +1 signal within user-input time period} {http://www.metastocktools.com} StHour:=Input("start Hour",0,23,12); StMin:=Input("start Minute",0,59,1); EnHour:=Input("end Hour",0,23,14); EnMin:=Input("end Minute",0,59,15); start:=Hour()>StHour OR Hour()=StHour AND Minute()>=StMin; end:=Hour()<EnHour OR Hour()=EnHour AND Minute()<=EnMin; start AND (end OR (start AND Alert(start=0,2))) ---8<--------------------------- [/code:1:626eb7e459] jose '-) http://www.metastocktools.com
Jose  
#8 Posted : 19 years ago
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)
And here's the rest: [code:1:129a8b48b7] =========== Time filter =========== ---8<--------------------------- {Intraday time filter} {Plots +1 signal within user-input time period} {http://www.metastocktools.com} StHour:=Input("start Hour",0,23,12); StMin:=Input("start Minute",0,59,1); EnHour:=Input("end Hour",0,23,14); EnMin:=Input("end Minute",0,59,15); start:=Hour()>StHour OR Hour()=StHour AND Minute()>=StMin; end:=Hour()<EnHour OR Hour()=EnHour AND Minute()<=EnMin; start AND (end OR (start AND Alert(start=0,2))) ---8<--------------------------- [/code:1:129a8b48b7] jose '-) http://www.metastocktools.com
wabbit  
#9 Posted : 19 years ago
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Sorry for changing stuff, Patrick I was having a look at my code posted previously, and decided it didn't look very neat. I have nested If() functions that could be easily sorted out to look much neater: if(l_StartDate->pfValue==0 && IntDate <= l_EndDate->pfValue) {a_psResultRec->psResultArray->pfValue= 1;} else if(l_EndDate->pfValue==0 && IntDate >= l_StartDate->pfValue) {a_psResultRec->psResultArray->pfValue= 1;} else if(IntDate >= l_StartDate->pfValue && IntDate <= l_EndDate->pfValue) {a_psResultRec->psResultArray->pfValue= 1;} is much more professional, yes? Although it is possible to join each of the three If() statements with ||, I think it is better in this second edited format. What say you? wabbit :D
Patrick  
#10 Posted : 19 years ago
Patrick

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)
What about using a while loop ... (if FirstDate = 0){FirstDate = a_psDataRec->psDate[1]}; While( date < lastdate and date>firstdate){ result = 1; } What do you think? ( I know this is notcorrect but you get the idea :D ) Patrick :mrgreen:
wabbit  
#11 Posted : 19 years ago
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
I dont think it would make much difference to the speed or execution in this instance. If() can be a little easier to read and therefore debug, but the While() is useful too. I am happy to use whatever you want to use. wabbit :D
Patrick  
#12 Posted : 19 years ago
Patrick

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)
If it wont be any faster then what's the point :D I will just stick with your code, especially because I don't want to think about a new way of writing it and actually writing it :D Patrick :mrgreen:
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.