{"id":34,"date":"2006-09-01T10:03:48","date_gmt":"2006-09-01T15:03:48","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/2006\/09\/01\/how-to-change-property-for-multiple-symbols-at-once\/"},"modified":"2014-12-04T04:43:47","modified_gmt":"2014-12-04T09:43:47","slug":"how-to-change-property-for-multiple-symbols-at-once","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2006\/09\/01\/how-to-change-property-for-multiple-symbols-at-once\/","title":{"rendered":"How to change property for multiple symbols at once."},"content":{"rendered":"

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:<\/p>

– Analysis -> Formula Editor:
– enter:<\/p>AB <\/span>= <\/span>CreateObject<\/span>(<\/span>"Broker.Application"<\/span>);
<\/span>st <\/span>= <\/span>AB<\/span>.<\/span>Stocks<\/span>(<\/span>Name<\/span>());
<\/span>st<\/span>.<\/span>DataSource <\/span>= <\/span>0<\/span>;
<\/span>Buy <\/span>= <\/span>0<\/span><\/code>

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

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).<\/p>

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

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

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.<\/p>","protected":false},"excerpt":{"rendered":"

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– […]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[53,54,18],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/34"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=34"}],"version-history":[{"count":1,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":800,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/34\/revisions\/800"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}