[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: Bar Count since certain date



PureBytes Links

Trading Reference Links

------------------------------------------------------------------------
You cannot reply to this message via email because you have chosen not
to disclose your email address to the group.

To reply:  http://groups.yahoo.com/group/equismetastock/post?act=reply&messageNum=5953
------------------------------------------------------------------------

Try this.
AA:=Input("mmddyyyy  date ",1011960,12312100,6262002);
Date1:=AA=Month()*1000000+DayOfMonth()*10000+Year();
count:=BarsSince(date1);
count:=count + Cum(If(count=0,1,0));
count


lhgoh99



--- In equismetastock@xxxxxxxxxxxxxxx, "bruneski 
<iniciante_2000@xxxx>" <iniciante_2000@xxxx> wrote:
> Hi Spyros! Back again!
> 
> Well your new formulation seems to work fine for most dates, but 
> fails for each day of December of each year up until 2001 (I didn't 
> really check why!). 
> 
> Now ... I do have a suggestion that might do the trick:
> 
> build numbers that represent complete dates 'positionally' (that 
is, 
> transforms, say, Nov 25, 2001 into 20011125).
> 
> There it goes:
> d:=Input("Day",1,31,1);
> m:=Input("Month",1,12,1);
> y:=Input("Year",1920,2030,2002);
> mydate:= 10000*y + 100*m + d;
> date:= 10000*Year() + 100*Month() + DayOfMonth(); 
> count:=BarsSince(mydate<=date); {use '<' if first day is not to be 
> counted}
> count:=count + Cum(If(count=0,1,0));
> count
> 
> Looks nice, doesn't it? Better yet, seems to work! :-D
> 
> Would you care to verify it?
> 
> Thanks for your enlightening insights!!! Take it easy.
> 
> 
=====================================================================
> --- In equismetastock@xxxxxxxxxxxxxxx, "SR" <raftsp@xxxx> wrote:
> > There are times (like this) when I feel like a beginner, too.
> > 
> > I hope that the newer version  fixes the bug.
> > If you see anything else please tell me. Here is the code:
> > -----------------------------
> > 
> > {BarsSinceDate}
> > 
> > d:=Input("Day",1,31,1);
> > m:=Input("Month",1,12,1);
> > y:=Input("Year",1920,2030,2002);
> > 
> > cond1:= d<DayOfMonth() AND m=Month() AND y=Year();{normal 
situation}
> > cond2:= d>DayOfMonth() AND m+1 =Month() AND y=Year();{change of 
> month}
> > cond3:= d>DayOfMonth() AND m=12 AND y+1=Year();{change of year}
> > 
> > count:=BarsSince(cond1 OR cond2 OR cond3);
> > count:=count + Cum(If(count=0,1,0));
> > count
> > 
> > -------------------------
> > The simplest solution would be of course this one:
> > 
> > d:=Input("Day",1,31,1);
> > m:=Input("Month",1,12,1);
> > y:=Input("Year",1920,2030,2002);
> > 
> > 
> > count:=BarsSince(d=DayOfMonth() AND m=Month() AND y=Year());
> > count
> > -------------------------
> > But this will display a line, only if the date you enter is a 
valid 
> one.
> > So one can use the above as long as he/she provides dates that 
are 
> present
> > in the chart.
> > 
> > I tried to get something that overcomes this restriction.
> > The logic was to first count the bars of an earlier date (a valid 
> one)
> > using:
> > 
> > count:=BarsSince(d<DayOfMonth() AND m=Month() AND y=Year());
> > 
> > and then add the dates where the indicator had zero values using:
> > 
> > count:=count + Cum(If(count=0,1,0));
> > 
> > But this was wrong because it didn't take into account the cases 
> where the
> > Day gets lower
> > as when for the 30th we proceed to the next month and Day is now 
a 
> lower
> > number!
> > I think I fixed that and I also fixed the case where we we have 
the 
> change
> > between Years.
> > 
> > Thanks for pointing out the problem.
> > 
> > Spyros
> > 
> > _________________________________________________
> > Message: 9
> >    Date: Thu, 02 Jan 2003 20:00:00 -0000
> >    From: "bruneski <iniciante_2000@xxxx>"
> > <iniciante_2000@xxxx>
> > Subject: Re: Bar Count since certain date
> > 
> > Hi Spyros! As a beginner with Metastock formula language I
> > implemented your suggestion (as an indicator) just to check how it
> > worked.
> > 
> > It seems to work fine most of the time, except for a few days at 
the
> > end of each month (try Nov 29 or Nov 30, 2002). How can that be?
> > Maybe something related to the '<' sign in the BarsSince 
condition?
> > 
> > BTW, what is the rationale for the condition 'd<DayOfMonth() AND
> > m=Month() AND y=Year()'. Does it mean that BarsSince counts from 
the
> > last time the condition was true?
> > 
> > And why is the assignment 'count:=count + Cum(If(count=0,1,0))'
> > necessary?
> > 
> > Thanks a lot.
> > 
> > 
> 
=====================================================================
> > 
> > --- In equismetastock@xxxxxxxxxxxxxxx, "SR" <raftsp@xxxx> wrote:
> > > {BarsSinceDate}
> > >
> > > d:=Input("Day",1,31,1);
> > > m:=Input("Month",1,12,1);
> > > y:=Input("Year",1920,2030,2002);
> > >
> > >
> > > count:=BarsSince(d<DayOfMonth() AND m=Month() AND y=Year());
> > > count:=count + Cum(If(count=0,1,0));
> > > count
> > >
> > > Spyros
> > >
> > > Message: 1
> > >    Date: Wed, 01 Jan 2003 15:52:35 -0000
> > >    From: "trend2trader <trend2trader@xxxx>" <trend2trader@xxxx>
> > > Subject: Bar Count since certain date
> > >
> > > hi list,
> > >
> > > is there a possibility to program an indicator which counts the
> > bars
> > > since a certain data i.e. how many bars since 1/1/2000?
> > >
> > > thanks in advance
> > > trend2trader
> > >
> > >
> > >
> > > _


To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/