New to AB, trying to learn Composites.

This code attempts to write an array to a composite, read it back from
the composite, and then display the results from the composite.

I'm sure the answer to this is painfully obvious to community members
with experience:  why am I seeing only zeros from the second loop,
even though lastvalue at the end of the trace is accurate?

Best, :)
Whitney

code:
/////////////////////////////////////////////////////////////
fi = "%1.0f";
test = IIf( True, 0, 0 );
testcum = Cum( test );
_TRACE( "initial lastval of testcum = " + StrFormat( fi, LastValue(
testcum ) ) );

for ( i= 1; i <= 5; i++ )
{
 test[i] = i;
 _TRACE( "test = " + StrFormat( fi, test[i] ) );
 testcum = Cum( test );
 _TRACE( "tescum = " + StrFormat( fi, testcum[i] ) );
}

_TRACE( "lastval of testcum = " + StrFormat( fi, LastValue( testcum ) ) );

farray = IIf( True, 0, 0 );
fcum = Cum ( farray );
_TRACE( "initial lastval of fcum = " + StrFormat( fi, LastValue( fcum
) ) );

sCompName = "~Test";

AddToComposite(test, sCompName, "C"
 ,flags = atcFlagResetValues
 |atcFlagCompositeGroup
 |atcFlagEnableInBacktest
 |atcFlagEnableInExplore
 |atcFlagEnableInPortfolio
);

farray = Foreign( sCompName, "C", fixup=False );
Cumfarray = Cum( farray );
for (f=1; f<=5; f++)
{
 _TRACE( "farray = " + StrFormat( fi, farray[i] ) );
 fcum = Cum( farray );
 _TRACE( "fcum = " + StrFormat( fi, fcum[i] ) );                
}
_TRACE( "lastval of farray after foreign = " + StrFormat( fi,
LastValue( fcum ) ) );

/////////////////////////////////////////////////////////////

trace:
------------------------------------------------------------
00000000 17:28:05.031 [3556] initial lastval of testcum = 0     
00000001 17:28:05.031 [3556] test = 1   
00000002 17:28:05.031 [3556] tescum = 1 
00000003 17:28:05.031 [3556] test = 2   
00000004 17:28:05.031 [3556] tescum = 3 
00000005 17:28:05.031 [3556] test = 3   
00000006 17:28:05.031 [3556] tescum = 6 
00000007 17:28:05.031 [3556] test = 4   
00000008 17:28:05.031 [3556] tescum = 10        
00000009 17:28:05.031 [3556] test = 5   
00000010 17:28:05.031 [3556] tescum = 15        
00000011 17:28:05.031 [3556] lastval of testcum = 15    
00000012 17:28:05.046 [3556] farray = 0 
00000013 17:28:05.046 [3556] farray = 0 
00000014 17:28:05.046 [3556] farray = 0 
00000015 17:28:05.046 [3556] farray = 0 
00000016 17:28:05.046 [3556] farray = 0 
00000017 17:28:05.046 [3556] lastval of farray after foreign = 15
------------------------------------------------------------




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:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to