Supporting Bid-Ask Trend and Time & Sales data in Real Time plugin

In my Real Time plugin, I'm sending bid & ask prices and sizes and last trade data in the RecentInfo structure but the Bid-Ask trend does not get updated, neither are the trades & bids/asks reflected in the Time & Sales window.

I experimented with the nBitmap and nStatus fields which are filled in the QuoteTracker sample but couldn't find a combination which gets the above 2 features working. Rest of the info is getting updated in Real-Time quote window.

  1. How do we support Bid-Ask trend and Time & Sales in real time plugin ? I couldn't find this documented anywhere in samples/forum/manual.
  2. In my experimentation above, I found that masks in nStatus don't have any effect and I can leave this field blank, and data still gets updated. Is this an obsolete field and superseded by nBitmap ?

I've tested this on x64 6.00.2 and 6.40.4.

Here is what you should do in your plugin:

void OnReceiveANewTick( LPCTSTR pszSymbol, int field, float price )
        // a structure where you keep per-symbol data
	CSymbolData *poSymData = GetSymbolDataPerTicker( pszSymbol );

	if( poSymData )
		time_t curtime = time(NULL);

		switch( field )
			case BID:		
				poSymData->m_oRecentInfo.fBid = (float) price;
			case OPEN:		
				poSymData->m_oRecentInfo.fOpen = (float) price;
			case ASK:		
				poSymData->m_oRecentInfo.fAsk = (float) price;
			case LAST:		
				poSymData->m_oRecentInfo.fLast = (float) price;

		struct tm *curtm = localtime( &curtime );

		poSymData->m_oRecentInfo.nBitmap = RI_LAST | ( poSymData->m_oRecentInfo.fHigh == 0 ? 0 : RI_HIGHLOW | RI_PREVCHANGE ) 
			| RI_TRADEVOL | RI_TOTALVOL | RI_BID | ( poSymData->m_oRecentInfo.fOpen == 0 ? 0 : RI_OPEN ) | RI_ASK | RI_DATEUPDATE | RI_DATECHANGE;	


		poSymData->m_oRecentInfo.nDateChange = poSymData->m_oRecentInfo.nDateUpdate = curtm->tm_year * 10000 + ( curtm->tm_mon + 1 ) * 100 + curtm->tm_mday;
		poSymData->m_oRecentInfo.nTimeChange = poSymData->m_oRecentInfo.nTimeUpdate = curtm->tm_hour * 10000 + ( curtm->tm_min ) * 100 + curtm->tm_sec;

1 Like

This didn't work. This is the same as the QT source with RI_52WEEK removed from nBitmap and RI_STATUS_BARSREADY removed from nStatus.

My source sends ticks which has multiple field updates (bids, asks & last price) and I was sending them together earlier. But I modified it to send one update at a time (bid, ask or last price, open doesn't change in the day) with incremented timestamps for each returned RecentInfo, it still didn't work.

Just to be sure, I also removed all field updates and only updated the fields in your snippet above (along with bid/ask sizes whenever bid/ask is updated), no change in behavior and bid/ask trend and time & sales don't show anything.

Edit: Your snippet above doesn't add 1900 to the year, not sure if you made it just now for illustration or copied from a working source. It would be great if there was a working sample for this.

Got this to work. Seems like these 2 only get updated if we send a window message with the RecentInfo structure for each ticker, even sending a catch all like in the QT sample won't work.

Not sure if this behavior is intentional, bid/ask trend and Time Sales can be updated with the results from the GetRecentInfo calls, sending an extra message shouldn't be required. The realtime quote window gets updated even if I don't send this message at all (either individual or catch all) since AmiBroker calls GetRecentInfo regularly (documented in docs as well).

Some clarification/update in the ADK docs regarding this would be good. From current docs, it seems that sending this message is only required if we want AmiBroker to call GetQuotesEx again to refresh the quotes.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.