amibroker

HomeKnowledge Base

How to change property for multiple symbols at once.

In order to automatically change a property for many symbols – instead of manual action in Symbol -> Information dialog one can use OLE automation.
For example – to unmark “Use only local database” option for all the symbols, it’s enough to run such SCAN:

– Analysis -> Formula Editor:
– enter:

AB CreateObject("Broker.Application");
st AB.Stocks(Name());
st.DataSource 0;
Buy 0

– Tools -> Send to Auto-analysis
– Apply to: All Symbols, N-last quotations = 1
– press SCAN

The other example shows how to rename all the symbols and replace .TO suffix with -TC (this may be useful when we want to use the existing historical data with a new datasource which uses a different symbology).

– Analysis -> Commentary
– enter:
AB CreateObject("Broker.Application");
sts AB.Stocks();
Qty sts.Count;
for( 
Qty 1>= 0)
{
 
st sts.Item);
 
Ticker st.Ticker;
 
printf("changing " ticker "\n" );
 
Length StrLen(Ticker );
 if( 
StrFind(ticker".TO") )
      
st.Ticker StrLefttickerLength-3)+"-TC";

– press APPLY
– use: VIEW -> Refresh All to see the changes in the symbol tree.

CAVEAT: The commentary formula above iterates through ALL SYMBOLS in the database, therefore, if your database is big (has more than 100 symbols) it may be SLOW, and you may experience “not responding” message, but it is NORMAL. It does not mean that program has stopped working. It just means that it has not completed iteration yet. In that case just WAIT and don’t touch it.

3 Responses to “How to change property for multiple symbols at once.”

  1. Grant Noble
    September 4th, 2006 | 11:01 pm

    for( i = Qty – 1; i >= 0; i– ) doesn’t work – are there some dodgy chareacters here ?

    for( i = Qty – 1; i >= 0; i–- ) parses OK

    looks like “n” should be “\n” too

  2. Grant Noble
    September 4th, 2006 | 11:04 pm

    Hey, where’d my backslash go ? What’s up here ?

  3. March 13th, 2007 | 10:38 am

    — is postdecrement unary operator. – is subtraction – it needs TWO arguments, not one – see User’s Guide.