Working on creating a script that updates a local SQL database with data from 
ESignal data feed.  I'm using the ODBC plugin, and I successfully have data 
writing to the database from what I call "instance 1", and another instance 
(#2) of AB configured to read that database.  Instance 2 of AB is configured to 
display only trading hours, while instance 1 (the data feeder/SQL populator) is 
set to display 24 hours(weekends filtered).

The issue I'm having, given the code below, seems to be related to 
timestamping.  Instance 1 shows daily candles from the esignal feed, with local 
database storage enabled, without "Show 24 hours trading" enabled.  There seems 
to be only dates, and not times associated with these daily candles (when 
viewing a daily chart) on that machine.  The crosshairs don't show any time... 
just date and barnumber.  When I hit the paramtrigger in my code below, it 
writes the array to the database with a timestamp of YYYY-MM-DD 00:00:00.000
As a result, AB instance 2, if I don't enable "Show 24 hours trading", I don't 
see any daily candles, because it thinks the price occured at midnight(off 
trading hours).

In all of this, obviously, I'm mixing intraday (1m) and EOD data in the same 
table.

The question is, what do I have to put in the database for AB to know that it's 
a daily candle data?  Do I have to add something to blank out the 00:00:00 
timestamp in my datetime string?  Will the DB accept a blank timestamp? Is that 
the way to go?  or is there another flag stored with the daily data in the AB 
database that I need to consider in my SQL database?

Any help would be greatly appreciated.

-Dan

Below is my code:

_SECTION_BEGIN("DATABASE");
if (ParamTrigger("write to DB","*"))
 {

odbcOpenDatabase("ODBC;DSN=DBONE;UID=Administrator;Trusted_Connection=Yes;APP=AmiBroker
 for Win32;WSID=SERVER;Network=DBMSSOCN;DRIVER={SQL Native 
Client};SERVER=SERVER");
odbcDisplayErrors( False );
DT=DateTime();
for( i = 0; i < ( BarCount - 1 ); i++ )
{ 
                if( NOT odbcExecuteSQL("INSERT INTO TestTable ([SYMBOL],[DATE], 
[OPEN], HIGH, [LOW], [CLOSE], VOLUME, OPENINT) VALUES ('"
+ 
Name()+"','"+DateTimeToStr(DT[i])+"',"+Open[i]+","+High[i]+","+Low[i]+","+Close[i]+","+Volume[i]+","+OpenInt[i]+");"))
 

{
  _TRACE("INSERT failed with following message : " +odbcGetLastError() ); 
}
}
}
_SECTION_END();
                        

Reply via email to