PureBytes Links
Trading Reference Links
|
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
------------------------------------------------------------
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.27/517 - Release Date: 11/3/2006
|