Am trying to store the data that amibroker gets from ib unto a database. 
However, found 
that amibroker doesn't seem to multitask very well. 

When i put amibroker to the background (collapse, switch to another 
application, 
desktop, etc) it stops storring data. If I switch to another chart it stops 
storring data 
(would be nice to be able to store information for several instruments).

Is this a limitation of amibroker, or am missing some setting or something.

Here is a copy of the AFL.

_SECTION_BEGIN("SQLinsert");
odbcOpenDatabase("ODBC;DATABASE=datastream;DRIVER={MySQL ODBC 3.51 
Driver};OPTION=0;PWD=root;PORT=0;UID=root");

if(IsEmpty(StaticVarGet("isInitialized")))
{
isInitialized = 1;
ultimo = WriteVal(Ref(DateTime(),-0),formatDateTime);
StaticVarSetText("ultimo",ultimo);
StaticVarSet("isInitialized" ,1);
}

ultimo = WriteVal(Ref(DateTime(),-0),formatDateTime);
if(ultimo != StaticVarGetText("ultimo"))
{
cierre = Close[0];
bajo = Low[0];
alto = High[0];
apert = Open[0];
vol = Volume[0];
StaticVarSetText("ultimo",ultimo);

temp= DateTimeConvert(0,Ref(DateTime(),-0));
temp1=int(temp / 10000);
fecha = NumToStr(temp1 + 1900,1.0,False);
temp = temp -temp1*10000;
temp1 = int(temp / 100);
fecha = fecha + "-" + NumToStr(temp1,1.0);
temp = temp - temp1*100;
fecha = fecha + "-" + NumToStr(temp,1.0) + " 
"+DateTimeConvert(5,Ref(DateTime(),-0));
fecha = fecha + ":" + DateTimeConvert(4,Ref(DateTime(),-0));
fecha = fecha + ":" + DateTimeConvert(3,Ref(DateTime(),-0));

symbol=odbcGetValue("Symbols",Name(),"id");
ultimo=odbcGetValueSQL("SELECT `date` FROM `ticks` WHERE `symbol` = "+symbol+" 
ORDER BY `Date` DESC LIMIT 1");

sqlqry=NumToStr(symbol)+", '"+ fecha+"', "+NumToStr(apert)+", 
"+NumToStr(bajo)+", 
"+NumToStr(alto)+", "+NumToStr(cierre)+", "+NumToStr(vol);
sqlqry="REPLACE INTO ticks (symbol, `date`, open, low, high, close, volume) 
VALUES 
("+sqlqry+")";
sqlqry=sqlqry+";";

odbcExecuteSQL(sqlqry);
GfxDrawText(ultimo+" "+cierre,20,20,400,100);
}
_SECTION_END();


Reply via email to