I happen to add symbols daily according to the index open price as strike price and weekly expiry dates for my options, I do find out the name of the symbol to be added in my AFL but then I manually add that symbol as of now, is there a way to add that symbol automatically. Like it should check if the symbol already exists, if not then add that particular symbol automatically when I run amibroker with the chart loaded with the said AFL prgram. Thanks in advance.
It can be done using OLE automation interface AmiBroker Object Model
ab = CreateObject("Broker.Application");
stks = ab.Stocks;
stk = stks.Item("NewSymbol");
if( stk )
{
printf("Symbol already exists\n");
}
else
{
printf("Adding symbol\n");
// if symbol already exists Add would not do anything anyway
stks.Add("NewSymbol");
ab.RefreshAll();
}
Thanks for the prompt solution, it is working just fine. But when I am using this code it shows warning Warning 503. Using OLE / CreateObject / CreateStaticObject is not multi-threading friendly.
should it create any issue with the performance of my AFL?
Why don't you check yourself if you see any difference in speed. And why don't you just press F1 key or double click on warning to get explanation for what the warning means Warning 503. Using OLE / CreateObject / CreateStaticObject is not multi-threading friendly.
Everything is already described in the manual and each answer readily available at your finger tips. Use F1 (help file).
So if you can, place the relevant code inside if
(conditional) statement so it is executed only when you really need it.
Ok thanks. Will make sure to run it only when needed.
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.