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

Re: [amibroker] Re: Sequence of two conditions



PureBytes Links

Trading Reference Links

Markus,
	try this

// example conditions
aa = C<O;  // down day
bb = C>O;  // up day

// First B After A
FB = bb AND ( BarsSince(Aa) <= Ref(BarsSince(bb), -1) 
              // special case when no previous bb
              OR ( BarsSince(Aa) 	// we DO have a previous 'aa'
                   AND 
                   IsNull(Ref(BarsSince(bb),-1)) // but no 'bb'
                 )
            );

if the aa and bb arrays look like this

110000001000011110000000 aa
000001110100000000011111 bb
000001000100000000010000 fb

is this what you wanted??

I'm assuming conditions 'aa' and 'bb' are mutually exclusive.

Note, the stuff after the 1st line of the above expression takes care of the 
case when there are no 'bb' prior to the first 'aa'

-- 
	Nigel


On Tue, 25 Mar 2003 08:50 am, IVA GmbH wrote:
> Dimitris,
>
> actually itīs not. Exrem and Valuewhen judge the occurence from the back
> ofthe chart while I try to find the first occurrence of a condition right
> after another condition has taken place.
>
> Example: I want to detect the first instance of b right after a has
> happened:
> a  a  a  b  b  b
>
> Using Valuewhen I would have to use Valuewhen(..,..,3). But I donīt know in
> advance how many occurrences of b take place. So I thought the only way to
> address this b is to find the first right AFTER the occurrence of a.
>
> Do you know what I mean???
>
> Thanks
>
> Markus
> ----- Original Message -----
> From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Monday, March 24, 2003 9:05 PM
> Subject: [amibroker] Re: Sequence of two conditions
>
>
> For
> cond1=a;
> cond2=b;
> you may have a sequence
> a, a, b, b, b, a
> with
> cond11=exrem(cond1,cond2);
> cond22=exrem(cond2,cond1);
> you will have
> a,    b,     , a
> ie only the forst occurrence of each a or b.
> Is this what you are looking for ?
> DT
>
> --- In amibroker@xxxxxxxxxxxxxxx, "IVA GmbH" <funnybiz@xxxx> wrote:
> > Folks,
> >
> > maybe you have a solution for the following:
> >
> > Iīd like to detect the first occurence of cond2 after cond1 has
>
> happened.
>
> > I seemingly canīt use Valuewhen function since it calculates from
>
> the last bar, not from cond1 (i.e. I nedd a calculation forward
> rather than backward).
>
> > So, in case that there are several instances of cond2 after cond1,
>
> I might get a wrong result.
>
> > Could anyone help me, please?
> >
> > Thanks a lot
> >
> > Markus
>
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Your own Online Store Selling our Overstock.
http://us.click.yahoo.com/rZll0B/4ftFAA/46VHAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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