Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 7/15/2006(UTC) Posts: 2
|
{ User input } type:=Input("OHLC values: [1]Day, [2]Week, [3]Month, [4]Year",1,4,1);
{ Day's start } DayStart:=DayOfMonth()<>Ref(DayOfMonth(),-1);
{ Week's start - reference "Calendar Week counter" indicator for accurate weekly signals} WkStart:=DayOfWeek()<Ref(DayOfWeek(),-1);
{ Month's start } MthStart:=Month()<>Ref(Month(),-1);
{ Year's start } YrStart:=Year()>Ref(Year(),-1); <---- Instead of Yearly, I want to get quarterly ???
{ Selected Daily/Weekly/Monthly/Yearly } start1:=If(type=1,DayStart, If(type=2,WkStart, If(type=3,MthStart,YrStart))); start:=start1 OR Cum(1)=2;
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Vultran
The first month of any quarter can be found by dividing (Month()-1) by 3 and testing the fractional result for zero..
Qstart:=Frac((Month()-1)/3)=0;
The first bar or leading edge of the first month in each quarter is then found by testing the current bar for TRUE (Qstart) and the previous bar for FALSE (Qstart=0). The use of either Alert() or ValueWhen() is preferable to Ref() when testing the logical state of the previous bar for the simple reason that my suggested alternatives do not imbed an N/A bar on bar one. To be fair, though, neither Alert() nor ValueWhen() can produce a result on bar one either
Qstart AND Alert(Qstart=0,2);
Qstart:=Frac((Month()-1)/3)=0;
Qstart {=TRUE} AND Alert(Qstart=FALSE,2);
Variations on the theme are as follows.
Qstart:=Frac((Month()-1)/3)=0;
Qstart * Alert(Qstart=0,2);
Qstart:=Frac((Month()-1)/3)=0;
Qstart AND ValueWhen(2,1,Qstart)=0;
Qstart:=Frac((Month()-1)/3)=0;
Qstart * Ref(Qstart,-1)=0; {NOT recommended}
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 3/21/2007(UTC) Posts: 1 Location: Boston Mass
|
Mr. Larson, you have a nice newsletter. [:)]
Bob
|
|
|
|
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)
|
Vutran320, to avoid plagiarism and copyright issues, please kindly include the original formula complete with copyright headers when posting copyright material in the public domain.
Thank you.
jose
|
|
|
|
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.