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

Re: [amibroker] What is wrong with this simple code



PureBytes Links

Trading Reference Links

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 -----
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

__._,_.___

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





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___