I am writing a program to feed real time data into QT.DLL plugin.
Using AmiBroker version 6.00.2
The data display error on Real time quote window.
It displays data correctly when RT data received but change back to today first data record immediately.
I read the QT source code in ADK 2.10a
I guess the below variables are give wrong information to AmiBroker
ri->nDateChange
ri->nTimeChange
ri->nDateUpdate
ri->nTimeUpdate
ri->nBitmap
ri->nStatus
in module of
Please help me to make it right!!!
Below is correspond module code from QT.dll
//////////////////////////////
// Timer Callback procedure
// It is called periodically to retrieve
// current quotes from QuoteTracker.
// It just issues request getLastQuote(ACTIVE)
// to QT HTTP server, reads the response
// and updates corresponding fields of recent info table
/////////////////////////////
VOID CALLBACK OnTimerProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_TIMER message
UINT_PTR idEvent, // timer identifier
DWORD dwTime // current system time
)
{
struct RecentInfo *ri;
if( idEvent == 199 || idEvent == 198 )
{
if( ! IsQuoteTrackerRunning() )
{
KillTimer( g_hAmiBrokerWnd, idEvent );
SetupRetry();
return;
}
try
{
CInternetSession oSession( AGENT_NAME, 1, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_DONT_CACHE );
CString oURL;
oURL.Format("http://%s:%d/req?getLastQuote(ACTIVE)", g_oServer, g_nPortNumber );
CStdioFile *poFile = oSession.OpenURL( oURL,1, INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE );
if( poFile )
{
CString oLine;
int iSymbol = 0;
if( poFile->ReadString( oLine ) )
{
if( oLine == "OK" )
{
while( poFile->ReadString( oLine ) )
{
TRACE( oLine + "\n" );
if( oLine.GetLength() < 20 ) continue;//AfxMessageBox("test");
GrowRecentInfoIfNecessary( iSymbol );
ri = &g_aInfos[ iSymbol ];
char *line = oLine.LockBuffer();
ri->nStructSize = sizeof( struct RecentInfo );
strcpy( ri->Name, strtok( line, "," ) );
int month = safe_atoi( strtok( NULL, "/-." ) );
int day = safe_atoi( strtok( NULL, "/-." ) );
int year = safe_atoi( strtok( NULL, "," ) );
int hour = safe_atoi( strtok( NULL, ":." ) );
int minute = safe_atoi( strtok( NULL, ":." ) );
int second = safe_atoi( strtok( NULL, "," ) );
float fOldLast, fOldBid, fOldAsk;
fOldLast = ri->fLast;
fOldBid = ri->fBid;
fOldAsk = ri->fAsk;
//->nTimeUpdate = ri->nTimeUpdate & ~0x07 + time(NULL) & 0x7;
ri->fLast = (float) safe_atof( strtok( NULL, "," ) );
ri->fBid = (float) safe_atof( strtok( NULL, "," ) );
ri->fAsk = (float) safe_atof( strtok( NULL, "," ) );
ri->fChange = (float) safe_atof( strtok( NULL, "," ) );
// tick
strtok( NULL, "," );
double dTemp = safe_atof( strtok( NULL, "," ) );
ri->iTotalVol = (int) dTemp;
ri->fTotalVol = (float) dTemp;
ri->fHigh = (float) safe_atof( strtok( NULL, "," ) );
ri->fLow = (float) safe_atof( strtok( NULL, "," ) );
ri->iBidSize = safe_atoi( strtok( NULL, "," ) );
ri->iAskSize = safe_atoi( strtok( NULL, "," ) );
dTemp = safe_atof( strtok( NULL, "," ) );
ri->iTradeVol = (int) dTemp;
ri->fTradeVol = (float) dTemp;
strtok( NULL, "," );
strtok( NULL, "," );
ri->fOpen = (float) safe_atof( strtok( NULL, "," ) );
ri->f52WeekLow = (float) safe_atof( strtok( NULL, "," ) );
ri->f52WeekHigh = (float) safe_atof( strtok( NULL, "," ) );
ri->nDateChange = 10000 * year + 100 * month + day;
ri->nTimeChange = 10000 * hour + 100 * minute + second;
if( ri->fLast != fOldLast || ri->fAsk != fOldAsk || ri->fBid != fOldBid )
{
ri->nDateUpdate = ri->nDateChange;
ri->nTimeUpdate = ri->nTimeChange;
}
ri->nBitmap = RI_LAST | ( ri->fOpen ? RI_OPEN : 0 ) | ( ri->fHigh ? RI_HIGHLOW : 0 ) | RI_TRADEVOL | RI_52WEEK |
RI_TOTALVOL | RI_PREVCHANGE | RI_BID | RI_ASK | RI_DATEUPDATE | RI_DATECHANGE;
ri->nStatus = RI_STATUS_UPDATE | RI_STATUS_BIDASK | RI_STATUS_TRADE | RI_STATUS_BARSREADY;
oLine.UnlockBuffer();
iSymbol++;
}
}
}
::SendMessage( g_hAmiBrokerWnd, WM_USER_STREAMING_UPDATE, 0, 0 );
poFile->Close();
delete poFile;
g_nStatus = STATUS_CONNECTED;
g_nRetryCount = RETRY_COUNT;
}
oSession.Close();
}
catch( CInternetException *e )
{
e->Delete();
KillTimer( g_hAmiBrokerWnd, idEvent );
SetupRetry();
return;
}
}
if( idEvent == 198 )
{
KillTimer( g_hAmiBrokerWnd, 198 );
SetTimer( g_hAmiBrokerWnd, 199, g_nRefreshInterval * 1000, (TIMERPROC)OnTimerProc );
}
}
///////////////////////////////
Moderator comment: Please use [code]
tags for code. I fixed your post, but please next time follow “how to use this site” docs.