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

Notification

Icon
Error

Options
Go to last post Go to first unread
Derek Worswick  
#1 Posted : Monday, May 7, 2012 11:48:11 AM(UTC)
Derek Worswick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 8/11/2005(UTC)
Posts: 104

Hi Solstices & Equinoxes Dates Roy Larson MetaStock Tips & Tools Wrote a neat formula to plot lines on changes to a new quarter of the year. http://forum.equis.com/forums/thread/22388.aspx Qstart:=Frac((Month()-1)/3)=0; Qstart AND Alert(Qstart=0,2); WD Gann commented that market changes can occur on SOLSTICES & EQUINOXES I would like to adapt Roy Larson’s formula to plot lines on March 21, June21 Sep t21 & Dec 21. My attempt is below Line:=(DayOfMonth()=21 AND Frac(Month()/3)=0); Line I do not know how to adapt the formula when the 21st falls on a weekend date. And do not understand the Alert function Hoping you can oblige, Derek
mstt  
#2 Posted : Monday, May 7, 2012 3:22:10 PM(UTC)
mstt

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)
Hi Derek

The Alert() function can be a useful substitute for the Ref() function. Its advantage over Ref() is that it does not generate N/A bars, something that Ref() cannot avoid doing. In the code you've reproduced the Qstart variable goes TRUE for every thrird month. What "Qstart AND Alert(Qstart=0,2)" does is AND Qstart with the state of Qstart on the previous bar. "Alert(Qstart=0,2)" carries forward the FALSE state of Qstart by one bar, so the total expression checks for Qstart TRUE on the current bar AND FALSE on the previous bar.

An Alert() function with a Periods parameter of 1 is actually not an alert at all. It merely shows the current logical state of the Expression parameter. To extend the logical state of Expression by 1 bar the Periods parameter must be set to 2, that is, 1 more than the required extenstion.

The formula you're having a problem with can be adapted to compensate for the 21st falling on a weekend most easily by testing for "greater than or equal" rather than just testing for "equal", and then qualifying the result by testing for a FALSE state on the previous bar.

Code:

DayOfMonth()=21 AND Frac(Month()/3)=0;
 {becomes}
DayOfMonth()>=21 AND Alert((DayOfMonth()>=21)=0,2) AND Frac(Month()/3)=0;
 {or}
D:=DayOfMonth()>=21;
D AND Alert(D=0,2) AND Frac(Month()/3)=0;


If you want to mark the bar prior to the weekend rather than the bar immediately after it you would need to introduce a forward reference using the Forum DLL. A forward reference using the standard Ref() function would introduce an N/A result on the last data bar, and that could lead to difficulties in several areas, not least being with explorations. Hope this helps.

Roy
Derek Worswick  
#3 Posted : Tuesday, May 8, 2012 2:53:12 AM(UTC)
Derek Worswick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 8/11/2005(UTC)
Posts: 104

Hi Roy, Many thanks for your solution to my problem on Solstice & Equinox dates …nice simple solution May I also thank you for your extensive explanation of the “ Alert “ function. This is very helpful for future use in formulas. Kind regards, Derek
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.