I am trying to create an index using ATC and I have calculated and 
stored the average percent change of the group of stocks in a symbol 
created from ATC using :

ATC(((c-ref(C,-1)/ref(C,-1))/Foreign("~sum","I"),"AVG_%_CH","C");

I now need to create my index but can't seem to get there.

I have tried many different ways including:
 
ATC(ref(Foreign("~sum","C"),-1) + Foreign("~AVG_%_CH","C")*ref
(Foreign("~sum","C"),-1),"~INDEX","C");

but this does not produce what I need.I realize I need access to the 
previous days "~INDEX" value in order to calculate the current 
days "~INDEX" value. I can calculate this with AFL but I want to 
create a symbol that holds the INDEX and I can't seem to figure out 
how to do this using ATC. Is there a way to do this using ATC that 
I'm missing or is it possible to do this another way and still have 
the INDEX contained in its own symbol.

Thanks in advance,
Tom

--- In [email protected], "trb0428" <[EMAIL PROTECTED]> wrote:
>
> Graham,
> 
> Thanks for this...but I don't see how I would use this with 
> AddToComposite? This code could accomplish the index task if I 
were 
> just looking to plot it, but I want to store the result in an 
> index "ticker" like when using ATC...can I use this code in my ATC 
> scan?
> 
> Thanks,
> Tom
> 
> --- In [email protected], Graham <kavemanperth@> wrote:
> >
> > from the help files is this piece of code to find the average of 
a
> > group of stocks
> > 
> > function CreateAverageForWatchList( listnum )
> > {
> >    // retrive comma-separated list of symbols in watch list
> >    list = CategoryGetSymbols( categoryWatchlist, listnum );
> > 
> >    Average = 0; // just in case there are no watch list members
> > 
> >    for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
> >    {
> >       f = Foreign( sym, "C" );
> >       if( i == 0 ) Average = f;
> >       else Average = Average + f;
> >    }
> >    return Average / i; // divide by number of components
> > }
> > 
> > Plot( CreateAverageForWatchList( 1 ), "Avg of WL 1", 
colorGreen );
> > 
> > You can change this to find the average percentage change of the 
> group
> > of stcoks and use this for teh addtocompoiste
> > 
> > 
> > --
> > Cheers
> > Graham
> > AB-Write >< Professional AFL Writing Service
> > Yes, I write AFL code to your requirements
> > http://e-wire.net.au/~eb_kavan/ab_write.htm
> > 
> > 
> > 
> > On 2/25/06, trb0428 <trbrowne@> wrote:
> > > I am hoping someone can lend advice on my approach. I am 
trying 
> to
> > > create indexes based on the sectors/industries I have set up. 
I 
> want
> > > the index to calculate the average percent change across all 
of 
> the
> > > stocks in the industry and adjust the index price each day
> > > accordingly.
> > > I have the following:
> > >
> > > sym = "~IndexTest";
> > >
> > > // Sums daily percent change into sym
> > > AddToComposite((C - Ref(C,-1)) / Ref(C,-1),sym,"C");
> > > //Used to count the number of symbols
> > > AddToComposite(1,sym,"I");
> > >
> > > How can I use the count that I have stored in "I" to divide 
> the "C"
> > > field within my index symbol and store the result?
> > >
> > > Also, I then need to multiply the daily percent change by the
> > > previous days close and add it to the index.... something like:
> > > AddToComposite((((C - Ref(C,-1)) / Ref(C,-1) / I)*Ref(C,-1) + 
Ref
> (C,-
> > > 1))+100,sym,"C");
> > >
> > > Can I run addtocomposite on a composite ticker and will it 
store 
> the
> > > last result? I don't believe this works....is there another 
way 
> to
> > > accomplish the same?
> > >
> > > Thanks for any suggestions.....
> > >
> >
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

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