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

Re: [amibroker] Learning Composites



PureBytes Links

Trading Reference Links

Whitney - Were you trying to run this in an indicator window?

Last I knew you can't write a composite from the Indicator environment. Run 
an  AA SCAN first.
I hacked away at what you have and ran it with a SCAN.   Without shifting 
the
range of i down a bit, the ~test was being written in the initial cells of 
the
ATC array.  I added First Value and Last Value to the range of your
for loop.
Barcount will let you know how many bars are in the current symbol being 
displayed
and the one I had loaded had 3738 bars.

What are you trying to accomplish by using ATC?  You may be able to do it 
without
iterating i over the range.

Hope this helps
JOE
_TRACE("DBGVIEWCLEAR");

fi = "%1.0f";

test = IIf( True, 0, 0 );

testcum = Cum( test );

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

testcum ) ) );

// Length of current symbol price array

LV = BarCount-1;

FV = BarCount - 10;

_TRACE("First Value= "+ FV +" Last Value= "+ LV);

for ( i= FV; i <= LV; i++ )

{

test[i] = i;

_TRACE( "test = " + StrFormat( fi, test[i] ) );

testcum = Cum( 1 );

_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=fv; f<=Lv; f++)

{

_TRACE( "farray = " + StrFormat( fi, farray[f] ) );

fcum = Cum( farray );

_TRACE( "fcum = " + StrFormat( fi, fcum[f] ) );

}

_TRACE( "lastval of farray after foreign = " + StrFormat( fi, LastValue( 
fcum ) ) );


Buy=Sell=0;

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

----- Original Message ----- 
From: "whitneybroach" <WhitneyBroach@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, October 27, 2006 6:44 PM
Subject: [amibroker] Learning Composites


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



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