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

[amibroker] Re: Recursive Boolean Expressions... Possible?



PureBytes Links

Trading Reference Links

Hi,
Can you not solve the problem by (effectively) re-defining varx 
within the expression i.e.

varx = C<Ref(L,-6) AND vary <6 AND NOT(C<Ref(L,-12) AND vary <6);

Haven't tried this and the presentation could possibly be tidied a 
bit. (Depending on what, exactly, you are trying to achieve, the very 
last term might need to be "Ref(vary,-6)<6" or some such.

Brian


--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> 
wrote:
>
> It depends. The loop is general-purpose solution and works always.
> 
> In some cases loops can be eliminated using Cum(), ValueWhen(),
> AMA, AMA2.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "sidhartha70" <sidhartha70@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Thursday, September 18, 2008 9:56 AM
> Subject: [amibroker] Re: Recursive Boolean Expressions... Possible?
> 
> 
> > Can I ask the master...?? TJ... Does this kind  of expression
> > absolutely require a loop structure?
> > 
> > TIA
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "gp_sydney" <gp.investment@> 
wrote:
> >>
> >> Graham,
> >> 
> >> That doesn't work either, in the general case, as varx is still 
not
> >> dependent on previous values of varx, only on previous values of 
your
> >> first "temp" statement.
> >> 
> >> Consider the simpler case:
> >> 
> >> temp = BarIndex() < 10;
> >> varx = temp AND NOT Ref(temp,-1);
> >> 
> >> temp now has the first 10 bars set to one and all other bars set 
to
> >> zero. varx will have the first 11 bars set to zero, since Ref
(temp,-1)
> >> is one (actually the first bar will probably be null) and then 
all
> >> subsequent bars will also be zero since temp is then zero.
> >> Consequently, varx would be completely zero, except perhaps for 
the
> >> first null.
> >> 
> >> Assuming this did work as suggested, compare to:
> >> 
> >> varx = BarIndex() < 10 AND NOT Ref(varx,-1);
> >> 
> >> Actually if the first bar was null due to Ref(varx,-1) being 
null,
> >> then varx would end up completely full of nulls (a problem to be 
wary
> >> of with nulls in loops). But say the first bar ended up being 
zero
> >> (perhaps the nz function was used), then the second bar would be 
one,
> >> since BarIndex is less than 10 and Ref(varx,-1) refers to the 
first
> >> bar which we just said was zero. The third bar would be zero, 
since
> >> Ref(varx,-1) now refers to the second bar which we just set to 
one,
> >> and the fourth bar would be one again. This would continue up to 
the
> >> 10th bar, after which all bars would be zero due to the BarIndex 
term.
> >> The first 10 bars of varx alternating between one and zero make 
the
> >> result different to the first version.
> >> 
> >> Regards,
> >> GP
> >> 
> >> 
> >> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@> wrote:
> >> >
> >> > try this
> >> > temp = C<Ref(L,-6) AND vary<6;
> >> > varx = temp AND NOT Ref(temp ,-6);
> >> > 
> >> > -- 
> >> > Cheers
> >> > Graham Kav
> >> > AFL Writing Service
> >> > http://www.aflwriting.com
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 2008/9/18 gp_sydney <gp.investment@>:
> >> > > No, you can't do that as the right-hand expression is 
evaluated
> > on the
> >> > > whole array before anything is assigned to the left-hand 
variable.
> >> > > That means that "varx" is effectively constant during the 
expression
> >> > > evaluation for the whole array. It's essentially the same as:
> >> > >
> >> > > temp = IIf(C<Ref(L,-6) AND vary<6 AND NOT Ref(varx,-
6),True,False);
> >> > > varx = temp;
> >> > >
> >> > > To do what you are suggesting would require a loop.
> >> > >
> >> > > Regards,
> >> > > GP
> >> > >
> >> > >
> >> > > --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" 
<sidhartha70@>
> > wrote:
> >> > >>
> >> > >> Hi All,
> >> > >>
> >> > >> Is it possible to have recursive boolean expressions...? 
i.e. the
> >> true
> >> > >> or false of the current value of the array depends on 
whether a
> >> > >> previous value of the array is true or false.
> >> > >>
> >> > >> So for example,
> >> > >>
> >> > >> varx = IIf(C<Ref(L,-6) AND vary<6 AND NOT Ref(varx,-
6),True,False);
> >> > >>
> >> > >> Would that work... or are recursive booleans like this not
> > allowed??
> >> > >>
> >> > >> TIA
> >> > >>
> >> >
> >>
> > 
> > 
> > 
> > ------------------------------------
> > 
> > Please note that this group is for discussion between users only.
> > 
> > To get support from AmiBroker please send an e-mail directly to 
> > SUPPORT {at} amibroker.com
> > 
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> > 
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > Yahoo! Groups Links
> > 
> > 
> >
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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