What I was actually trying to point out was that if the result is true of all the conditions are true you do not even need to use IF or IIF Even if one of the conditions need to be false to give true result you can do this, eg if C2 needed to be false
Result = Trigger and C1 and C2==0; -- Cheers Graham Kav AFL Writing Service http://www.aflwriting.com On 26/08/07, Fred Tonetti <[EMAIL PROTECTED]> wrote: > > > > Forgetting for a minute which form is array oriented and which isn't, I'm > not sure why you see that much distinction in terms of simplicity or > complexity between a nested if this … > > > > Result = False; > > > > If (Trigger == True) > > { > > If (C1 == True) > > { > > If (C2 == True) > > { > > Result = True; > > } > > } > > } > > > > … and a nested iif like this … > > > > Result = iif(Trigger, > > iif(C1, > > iif(C2, True, False), > > False), > > False); > > > ------------------------------ > > *From:* [email protected] [mailto:[EMAIL PROTECTED] *On > Behalf Of *lifes_student_1 > *Sent:* Saturday, August 25, 2007 10:25 PM > *To:* [email protected] > *Subject:* [amibroker] Re: getting an error in my if statement > > > > using iif(this and that and another, 1,0) wouldn't be too bad. It > would (for me) get really messy and hard to read to try nested iif > statements though. I appreciate your help. > > --- In [email protected] <amibroker%40yahoogroups.com>, Graham > <[EMAIL PROTECTED]> wrote: > > > > there are different ways to achieve things, for simple conditions to > > give true/false result you can simply use statement with OR/AND. The > > following assigns true to results if all 3 conditions are true on > the > > same bar > > > > Result = Trigger AND C1 AND C2; > > > > to assign values to the variable for true/false result, these values > > can be arrays are scalar > > > > Result = iif( Trigger AND C1 AND C2, A, B ); > > > > Nested IIF can also allow you to work through combinations of the > > conditions to give different resulting values. Just by placing the > > more stringent first and work from there > > > > Result = iif( Trigger AND C1 AND C2, A, iif( Trigger AND C1, B, iif( > > Trigger AND C2, C, iif( C1 and C2, D, E )))); > > > > These are much easier and straightforward than looping. I only use > > loops if the results I want depend on previous values of the same > > array for the current value, or to isolate a particular repeating > > occurence to only use the first occurence and ignore the rest (where > > other simple methods do not work). Loops can slow down the running > of > > AFL and best to be avoided unless really necessary. They can also > tie > > your brain up in knots getting the logic correct when a simple > method > > is easier and faster. > > > > > > -- > > Cheers > > Graham Kav > > AFL Writing Service > > http://www.aflwriting.com > > On 26/08/07, lifes_student_1 <[EMAIL PROTECTED]> wrote: > > > It's a bit more complicated than my example. I need to check for > > > several cases and I would generally use an if statement for > something > > > like this. Something like: > > > > > > result = false; > > > if (trigger == true) > > > { > > > if (c1 == true) > > > { > > > if (c2 == true) > > > { > > > result = true; > > > } > > > } > > > } > > > > > > --- In [email protected] <amibroker%40yahoogroups.com>, Graham > <kavemanperth@> wrote: > > > > > > > > Not knowing what you are trying to do why not try the simpler > and > > > > faster IIF function > > > > > > > > -- > > > > Cheers > > > > Graham Kav > > > > AFL Writing Service > > > > http://www.aflwriting.com > > > > > > > > > > > > > > > > On 26/08/07, lifes_student_1 <suedeuno@> wrote: > > > > > Thanks. Why can't I do the following though that should > result in > > > a > > > > > boolean: > > > > > > > > > > color = colorLime; > > > > > color2 = colorRed; > > > > > i1 = colorLime; > > > > > c1 = ((i1 == color OR i1 == color2)); > > > > > if (c1 == true) > > > > > {... > > > > > > > > > > > > > > > This doesn't work. I guess I'm not used to AFL. > > > > > > > > > > > > > > > > > > > > --- In [email protected] <amibroker%40yahoogroups.com>, > "Thomas Z." <tzg@> wrote: > > > > > > > > > > > > You need a loop and then you could write if(barsback[i] < 6) > > > > > > > > > > > > The other way would be to use IIF() > > > > > > > > > > > > Regards > > > > > > Thomas > > > > > > www.patternexplorer.com > > > > > > > > > > > > > > > > > > > > > > > > From: [email protected] <amibroker%40yahoogroups.com> > > > [mailto:[email protected] <amibroker%40yahoogroups.com>] > > > > > On Behalf > > > > > > Of lifes_student_1 > > > > > > Sent: Saturday, August 25, 2007 8:28 PM > > > > > > To: [email protected] <amibroker%40yahoogroups.com> > > > > > > Subject: [amibroker] getting an error in my if statement > > > > > > > > > > > > condition1 = cross(close, ma(close,20)); > > > > > > barsback = BarsSince(condition1 == true); > > > > > > if(barsback < 6) > > > > > > {... > > > > > > > > > > > > I'm getting error 6 on barsback in if statement. condition1 > is > > > set > > > > > and > > > > > > works as I've tested it elsewhere. What am I doing wrong? > > > > > > > > > > > > (Condition in IF, WHILE, FOR statements has to be Numeric or > > > > > Boolean > > > > > > type. You cannot use an array here....) > > > > > > > > > > > > > > > > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > ------------------------------ > I am using the free version of SPAMfighter for private users. > It has removed 42 spam emails to date. > Paying users do not have this message in their emails. > Try SPAMfighter <http://www.spamfighter.com/len> for free now! > >
