[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Populating MS SQL database with data from esignal



PureBytes Links

Trading Reference Links

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();
			



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/