Thanks Keith and Ed. I understand now. I guess I will have to think
more in terms of arrays than array elements. This is a bit like
functional programming; will need to dust off some of the old school
books.

Regards,

Drew





--- In [email protected], Keith McCombs <[EMAIL PROTECTED]> wrote:
>
> Drew --
> Notice that the IIF() operator took only one line of code, while the 
> for() and if() operators took eight lines. 
> 
> Array operations are much more efficient and much less error prone.
 Use 
> them when ever possible!!
> Use for() *ONLY* when you have to.
> -- Keith
> 
> Edward Pottasch wrote:
> >
> > IIF operates on an array en returns an array. So if you want to
simple 
> > fill the array "position" with 1 if Buy is 1 you can simple do:
> >  
> > position = Buy;
> >  
> > if you like to use the IIF operater the equivalent is:
> >  
> > position = IIF(Buy,1,0);
> >  
> >  
> > if you like to use a loop the equivalent is:
> >  
> > position = 0;
> > for ( i = 0; i < BarCount; i++) {
> >  
> >     if (Buy[ i ] == 1) {
> >        
> >         position[ i ] = 1;
> >    
> >     } else
> >  
> >         position[ i ] = 0;
> >  
> >     }
> >  
> > }
> >  
> >  
> > rgds, Ed
> >  
> >  
> >
> >     ----- Original Message -----
> >     *From:* thomasdrewyallop <mailto:[EMAIL PROTECTED]>
> >     *To:* [email protected] <mailto:[email protected]>
> >     *Sent:* Sunday, March 11, 2007 11:57 AM
> >     *Subject:* [amibroker] What is wrong with this simple code
> >
> >     Buy = cross ( Close, MADaily );
> >     for ( i = 1; i < BarCount; i++)
> >     {
> >     IIf (Buy[i], position[i] = 1, 0);
> >     }
> >
> >     I run an explore and get position[1] == 0 and the remainder of the
> >     array == 1 ( there are only two buy signals triggered). Is there
> >     something about the Buy array I am missing?
> >
> >     Best regards,
> >
> >     Drew Yallop
> >
> >
>


Reply via email to