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

Re: [amibroker] New Question on Watchlist Averages



PureBytes Links

Trading Reference Links

to start with you only need to select last quotation=1. if all quotations
are selected then it will run through for every bar which is unnecessary.
Remember to also have a buy statement in the AFL so that you can scan. Just
Buy=1; will do.

AFL goes through completely for each symbol once. Each command is completed
before proceeding to the next line in the AFL

the if(inwatchlist(1)) is done then proceeds to the next if statement. when
completed it goes to next symbol
AFL will check if each IF statement is true for every symbol and add the
appropriate fields to the coomposite

The trick to finding average prices for a watchlist is in how you read the
data from the composite, not in how you input it. Simplest is to do as I
suggested. Just add in the prices and number to the composite and do the
math of averaging when you use the composite

AB does have the watchlists stored in its database and checks this listing

If you have selected not to pad to a reference symbol in the AA Settings
then if a symbol does not have data for a particular day it will not add
anything to the composite. This is why adding 1 to the field helps in
getting average fo what stocks were traded on that day
If you want to pad (say to an index that has data for every market day) it
will add the last traded close price and a 1 to the composites


here is a simple example, I also use the name of the watchlist in the
creation of the composites
Buy=1;//

if(InWatchList(0))
{
Comp = "~"+CategoryGetName(categoryWatchlist,0);
AddToComposite(C,Comp,"C");
AddToComposite(1,Comp,"I");
}

You can also loop through
for(w=0;w<63;w++)
{
if(InWatchList(w))
{
Comp = "~"+CategoryGetName(categoryWatchlist,w);
AddToComposite(C,Comp,"C");
AddToComposite(1,Comp,"I");
}
}


by selecting the composite symbol, here is the code for plotting
compavg = c/i;
plot(compavg,"Group Avg Price",colorgreen,styleline);



you can also do this for groups, industries or sectors etc


-- 
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 10/08/06, Ken Close <ken45140@xxxxxxxxx> wrote:
>
>  Graham:
>
> Will this actually work and how does it work?
>
> Here is what I do not understand....please see each of my questions and
> respond to them all, please.
>
> I have a series of if statements checking whether the symbol is in the
> watchlist.
>
> if(InWatchlist(1))
>     Create the ATCs associated with WL1
>
> if(InWatchlist(2))
>     Create the ATCs associated with WL2
>
> etc for maybe 10 or 15 more watchlists.
>
> All of this saved in one AFL file.
>
> Load this file into AA window, set All Symbols, and All Quotations, then
> click SCAN
>
> *Does the program just SCAN thru 8000 symbols only ONCE or does it scan
> thru all symbols times the number of IF statements?  <<<< Key Q1*
>
> *If it only scans once, how do the multiple ATC statements work? Does the
> program keep track of only those symbols in the WLists?*  I think about a
> symbol starting with Z being in the first watchlist.  AB is not going to get
> to the Zs until some minutes later so how does it add just the Z (which is
> in WL1) to the ATC associated with WL1?   *<<<<< Key Q2.*
>
> I dont think it can and thus just do not appreciate the suggestion that
> the ATCs are the best way to calculate all of the ATC avgs for different WLs
> and still scan all symbols like TJs msg said.
>
> I just do not understand.....and so far, try as all you helpful folks
> have....I have not heard an explanation that makes sense on how to do
> this.....other than BatMan.  THAT makes sense but I wish I understood how to
> do it in just code or with scripts or......
>
> Ken
>
>  ------------------------------
> *From:* amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] *On
> Behalf Of *Graham
> *Sent:* Wednesday, August 09, 2006 6:43 PM
> *To:* amibroker@xxxxxxxxxxxxxxx
> *Subject:* Re: [amibroker] New Question on Watchlist Averages
>
> Simple approach does work better and easier
>
> if (InWatchList(11))
>  {
>   AddToComposite(C,"~Z01Aerospace_Defense","c");
>   AddToComposite(1,"~Z01Aerospace_Defense ","I");
>  }
>
> Now when you do it the count of stocks will be in open interest
>
> Whe you want to find an average of this you then use
>
> setforeign("~Z01Aerospace_Defense ");
> xAvg = C/I;
> restorepricearrays();
>
> --
> 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
> <http://e-wire.net.au/%7Eeb_kavan/ab_write.htm>
>
> On 10/08/06, dan_public@xxxxxxxxxxx <dan_public@xxxxxxxxxxx > wrote:
> >
> >  I agree 100% with TJ!   VERY strongly recommended.  I have five scans
> > that create and/or use ATC composites.   Total run time is about 45 minutes
> > per day.   However, when I display the ATC symbols or use them in further
> > analysis, response time is very fast.
> >
> > Note that this is a standard Data Warehouse methodology.
> > Pre-aggregation and pre-processing of data can take a long time, but the
> > user sees the processed results very quickly.
> >
> > Regards,
> >
> > Dan.
> >
> >
> > -------------- Original message --------------
> > From: "Tomasz Janeczko" < groups@xxxxxxxxxxxxx>
> >
> > Hello,
> >
> > You would need to check for Null values and/or use Nz (null to zero)
> > because of the fact
> > that if you don't have data for particular security Foreign() will give
> > you null values at the beginning of the array.
> >
> > Personally I would advice using AddToComposite in a regular way (scan
> > over entire database).
> > This way you would arrive to correct results faster and with less code.
> > This is so because plain scan
> > with addtocomposite does not involve any loops therefore it is fast even
> > if larger number of symbols is
> > being analysed. Especially once your needs grow over time and you will
> > want to calculate averages
> > not only for few watchlists but also for some industry groups, etc.
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> >
> > ----- Original Message -----
> > *From:* Ken Close <ken45140@xxxxxxxxx>
> > *To:* amibroker@xxxxxxxxxxxxxxx
> > *Sent:* Wednesday, August 09, 2006 8:44 PM
> > *Subject:* [amibroker] New Question on Watchlist Averages
> >
> > I have been making some progress using this code, I think from the help
> > files and/or mentioned here on the list:
> >
> > 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
> > }
> > I am creating averages of various watchlists and it is working....except
> > for.....
> >
> > The resulting average is no longer than the watchlist member with the
> > least or shortest amount of data.
> > If I have 20 members, 19 of which have data going back into the early
> > 90s but 1 member has data for the last 6 months, then the average which is
> > created is only 6 months long.
> >
> > Is there any modification to the above code such that an average for
> > each date will be created from which ever members have data for that date.
> > In my example, I would get an average based on 19 members up until 6 months
> > ago whereupon the average would be based on 20 members.
> >
> > Can this code do that? If not, how could the code be altered to
> > accomplish that.
> >
> > Thanks to all who are trying to help me with this. Some of the other
> > suggested approaches, using jscript (thanks Dan), etc, have been a little
> > daunting and I was able to get the above to work until I discovered the
> > truncated data (shortened average to the shortest list member).
> >
> > Ken
> >
> >
>
>
>
> 
>