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
|