That would give the number of times within the period that a close was
higher than its *immediately* preceding close. But, it would not give
the number of times that the current close was higher than *all*
preceding closes for that period as is being requested.
There may
be a more direct way, but the following would probably do it
for
you:
Count = 0;
for (i = 1; i <= 5; i++) {
Count +=
IIF(Close > Ref(Close, i * -1), 1, 0);
}
Condition = Count >=
4;
--- In amibroker@xxxxxxxxxps.com,
"Gordon Sutherland" <gosuth@xxx>
wrote:
>
> Try the
following:
>
> HigherClose = C > Ref(C,-1);
>
HigherThanLast4 = Sum(HigherClose,5) > 4;
>
Plot(HigherThanLast4,"",colorBlue,2);
>
>
Cheers,
>
> Gordon Sutherland
>
> -----Original
Message-----
> From: amibroker@xxxxxxxxxps.com
[mailto:amibroker@xxxxxxxxxps.com]
On Behalf
> Of ozzyapeman
> Sent: Friday, 12 September 2008
12:36 p.m.
> To: amibroker@xxxxxxxxxps.com
>
Subject: [amibroker] Close > At least 4 of the previous 5 Closes
>
>
> Quick question - is there a compact way to write the
following:
>
> Close > At least 4 of the previous 5
Closes
>
> I know I can write out each case like:
>
> Case_1 =
> C > ref(C,-1) and C > ref(C,-2)and C >
ref(C,-3)and C > ref(C,-4)and
C >
> ref(C,-5)
>
>
Case_2 =
> C < ref(C,-1) and C > ref(C,-2)and C > ref(C,-3)and
C > ref(C,-4)and
C >
> ref(C,-5)
>
>
etc....
>
> and then write if Case _1 or Case _2 or Case_3 or
...
>
> But I'm guessing there must be a simpler way to do
this?
>
> Any feedback appreciated.
>