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

[EquisMetaStock Group] RE: Re: Bar Count since certain date


  • To: <equismetastock@xxxxxxxxxxxxxxx>
  • Subject: [EquisMetaStock Group] RE: Re: Bar Count since certain date
  • From: "SR" <raftsp@xxxxxxxxx>
  • Date: Fri, 3 Jan 2003 04:57:09 -0800
  • In-reply-to: <1041594635.1015.47009.m12@xxxxxxxxxxxxxxx>

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=5941
------------------------------------------------------------------------

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@xxxxxxxxxxx>"
<iniciante_2000@xxxxxxxxxxx>
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/