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

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



PureBytes Links

Trading Reference Links

Thanks for your input on this chaps. Certainly cleared some fog in my
head. All sorted now.


--- In amibroker@xxxxxxxxxxxxxxx, "gp_sydney" <gp.investment@xxx> wrote:
>
> Brian,
> 
> As you say, it depends on what the original intention was. There are
> two ways to interpret a statement like:
> 
> varx = Ref(varx,-1) + 1;
> 
> The first is the way it actually works now, where each element in the
> new varx is the previous element in the old varx incremented by one.
> So if the original varx array has:
> 
> varx[10] = 1
> varx[11] = 27
> varx[12] = 39
> varx[13] = 102
> 
> The new varx array will have:
> 
> varx[11] = 2
> varx[12] = 28
> varx[13] = 40
> varx[14] = 103
> 
> The other way, which is what I was talking about (as I thought it was
> what was being asked about), is where the value at each bar is updated
> iteratively bar by bar as it would be in a loop. So if we assume that
> varx[10] is still one (but it would depend on what came before), then
> we would end up with:
> 
> varx[11] = 2 (1+1)
> varx[12] = 3 (2+1)
> varx[13] = 4 (3+1)
> varx[14] = 5 (4+1)
> 
> This is equivalent to the loop code:
> 
> varx[i] = varx[i-1] + 1;
> 
> Regards,
> GP
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "brianw468" <wild21@> wrote:
> >
> > 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@> 
> > 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@>
> > > 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/