Connection Status Check

When using IB as data source, I'd like to restart IB TWS or Amibroker in case the connection gets interrupted, but would like to get a notification if it does. Is it possible to periodically check that the connection to IB is green or blue (that it is ok)? Is this logged somewhere?

if you load the IBController you can check, see http://www.amibroker.com/at/

Thank you for your reply, but I am referring to the IB data source for streaming data: http://www.amibroker.com/ib.html

yes but if you also install the IB Controller you can access this type of information using for instance

ibc = GetTradingInterface("IB");

if( ibc.IsConnected() ) // check if connection to IB was successfull
{
    // here add code for what you want to do 
}

I cannot find any information within the IB Controller related to IB as data source and its connection status. IBC can have a good connection to TWS, but it would not mean that streaming data would be received.

i leave this for someone else to answer. All I know is that you can check if you are connected. You could also check how long ago the last quote was received with regular AFL. If for instance you received the last quote outside of a certain limit then you could do a reconnect using the IB controller.

Yes, the connection check is for IBC, but IB as data source has a separate connection and IP. They are completely separate entities for Amibroker. Checking how long ago the last quote was received is also an option, but I was hoping there is a specific log or code that shows if connection is ok just as the CONN box on the bottom right corner of Amibroker which goes from RED to BLUE to GREEN.

You can check last update date stamp using GetRTData on actively traded symbol such as SPY. If is is not current, it means problem. Connection itself is NOT indicative because plugin can be connected to TWS while TWS may have issues receiving data.
Checking actual quote update date/time stamp is better than anything else.

1 Like