Graham, I am endlessly surprised when people say they could not found the description when it sits under F1 key. Type AMA in the AFL editor and press F1 key. ================================== You don't need to search at all. Just press F1.
So AMA *IS* described to the level of every single bit in (of course) the User's Guide AFL function reference, available from F1 key in the AFL editor. http://www.amibroker.com/guide/afl/afl_view.php?ama (see comment that provides actual looping EQUIVALENT for AMA). Best regards, Tomasz Janeczko amibroker.com ----- Original Message ----- From: "Graham" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Friday, September 19, 2008 10:14 AM Subject: Re: [amibroker] Re: Recursive Boolean Expressions... Possible? > Generally speaking, if your variable requires a previous value of that > variable to determine current value then you need to use a loop > Other areas that can require looping is items such as trail stops, > where a subsequent Buy true condition can reset the trail price levels > to that newer bar > > > Of course there are built in functions that can do this within the > limits of their capabilities, eg AMA > > In the case of this thread it was not entirely clear just having the > line of code as to what the intent was > var = condition AND NOT ref(var,-6); could be interpreted differently as > either > var = condition and not ref(condition,-6) or in its raw state > in the raw state as shown it does require looping. > AMA function was mentioned somewhere in the thread, not even sure if > to say that it can be used for this. I am not at all clear on using > AMA as I have not yet found a description of exactly what the > algorithm is, I have only ever found examples of putting values into > it. > > > -- > Cheers > Graham Kav > AFL Writing Service > http://www.aflwriting.com > > > > 2008/9/19 sidhartha70 <[EMAIL PROTECTED]>: >> In answer to your question Brian, I ended up using a loop. >> Seeing the power of AFL, I often find myself resisting the use of >> loops, but then wrestling with the neccessary code to achieve my goals >> without using a loop. >> This seems to be a problem I hit quite consistently... which is a >> general uncertainty about whether I can achieve what I want without a >> loop or not. As it goes I usually waste time in that minor feedback >> loop for a while!!! >> >> >> --- In [email protected], "brianw468" <[EMAIL PROTECTED]> wrote: >>> >>> Thanks "GP", but I think your latest contribution muddies the waters >>> a bit. My understanding of the original question is that varx would >>> always be boolean - ie 1 or 0 (True or False)whereas your example >>> treats it as an integer variable. >>> The issue revolves around the real question - ie is the questioner >>> asking if a single line statement can contain a recursive element >>> (answer is probably NO) - or is the aim to solve a particular coding >>> problem without using a loop, where the answer could well be that >>> there are work-arounds. The guy who started this thread should >>> clarify what he is trying to do. Otherwise, further discussion is a >>> bit pointless. >>> >>> Brian >>> >>> --- In [email protected], "gp_sydney" <gp.investment@> >>> 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 [email protected], "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 [email protected], "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: <[email protected]> >>> > > > 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 [email protected], "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 [email protected], 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 [email protected], "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 >> >> >> >> > > ------------------------------------ > > 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 > > >
