Amibroker crashes whenever pops up alert in Interactive Brokers TWS - IB Data plugin

Amibroker (Profissional 32-bit 6.20.1) crashes whenever pops up alert in Interactive Brokers TWS (963.3 32-bit). Otherwise the IB Data plugin (2.0.9) works pretty well.
Does anyone have an idea on how to fix it?

Precisely what alert do you mean? Do you have the formula? Displayed by PopupWindow function? Or... ?

There is simply not enough details in your post to be able to
a) reproduce the problem you are having
b) help you

Sorry for the lack of information, I thought It could be a known issue. Specifically, it was the pop-up alert that the account has not enough projected overnight margin, not in compliance with Reg T at 4pm EST. As soon as it pops up in the TWS, AB closes down, not even running a scan. The only thing running is the real quote monitor and RT feed from IB.

"15:50:11:249 -> 4-2--1-2148-Based upon a review of your positions and qualifying equity, your account is not projected to be in compliance with the daily increase in margin requirements from intraday to overnight levels. Note that accounts which report a margin deficiency when overnight requirements go into effect are subject to forced liquidation of positions to ensure margin compliance. To avoid this action, please review your "Look Ahead" account balances within the TWS Account Window and take the steps necessary to reduce margin exposure."

Oh, so that is Traders Workstation (TWS) popup, not AmiBroker popup.
That changes things quite a bit.

This will need to be reproduced in controlled environment (i.e. we will need to somehow find a way for TWS to display popup in 'controlled' way and see if that causes reproducible problem).
Only when it is reproducible it can be fixed.

Also with "closes down" - does it mean that you don't see any message (like this for example

Yes, indeed TWS alert, but AB that closes (shuts) down without warning (no, I don't see any message).
It is easy to control the experiment, using an paper trading account, make sure to have a position intraday, say in ES or ZN, that will trigger an overnight margin call (usually the double). I will try this experiment tomorrow with the 64-bit AB and TWS. My guess is that could be the java 64-bit VM, where as the TWS is 32-bit. I will test it tomorrow and let you know.
Does AB records a log when it crashes?



If there is a large enough position in ES or ZN to trigger the overnight margin call, the alert will pop-up twice, at 3:50 and 4:00 PM EST, causing AB to crash both times (Again, AB 32-bit and TWS 32-bit)

Thank you for providing extra information. Will be looking into this and let you know about the results.


IB Controller has a feature to add Error Code to "Error Code Ignore List". If Plugin can be made to include similar feature so as to avoid abrupt crashes.

i confirm the same issue. Was it resolved?


You can try running TWS Gateway instead. The TWS API calls should NOT result in ANY blocking GUI display, because blocking modal message boxes that require human intervention disrupt message processing. Interactive Brokers should fix THEIR software and stop displaying stupid alert boxes when they are sending error via API.

I tried with IBGATEAWAY and the problem persists. I check the error code in IB controller, and there indeed is a error code for margin violation, but in that case there is no gui involved.
This makes it quite difficult to use AB for monitoring the market or place trades in critical situations. NOte that this message is generated when available fund or available liquidity are low, so in the first case there could still be a large liquidity, and it can happen very often even using low leverage, and being far from margin calls.


I took up with IB to provide datafeed functions by delinking error messages. They said, it is to handled by user application/plugin, as is done by Sierra Charts, motivewave etc.

I got a similar problem recently (sent 2 crash reports to support). AB crashed when I got a notice (popup window) from IB for rolling my futures position, reported by IB Controller as error 2148.

So this problem is not specific to margin call, but could happen anytime when IB sends a simple notice. As I understand it, IB shouldn't use this way to notify users, weird. It's definitively scary although I can live with, only need to be more careful at some specific time. Of course a workaround in AB would be simpler as I doubt IB will do anything about it alas...

@rvdesh @jonnycash Btw did you try to uncheck 'Display message in a new window' in setup of TWS/Alerts ? I'm not sure it can stop IB popup alerts/notices from crashing AB though, it's supposed to be about technical analysis alerts but you never know...I hope it helps.

As I said: in Amibroker crashes whenever pops up alert in Interactive Brokers TWS - IB Data plugin

we will need to somehow find a way for TWS to display popup in 'controlled' way and see if that causes reproducible problem). Only when it is reproducible in controlled environment it can be fixed.

Software can not be developed this way that we are waiting for hours until IB chooses to display stupid message that steals focus, stops processing messages in normal way or does other forbidden stuff in Windows. They are doing something weird with their "messages" not conforming to Windows UI guidelines and that is causing problems.


Is IB Data Plugin open source? If so, please give details for giving a try to sort out the issue.

see this link, first line:

also if you are a good programmer:

I will add, I just updated to the latest version this weekend. Before when I got the IB popup it created a popup notification in IB asking if you wanted to try and recover the software and allowing you to report the problem. Now it just completely closes AB. Happens every time I put on a large futures position and get a margin warning.


Write to IB to provide a way (an option) NOT to display messages in blocking message boxes. As I wrote, API calls should return error codes and NOT cause blocking message boxes that needs clicking. The IB "design" that forces user to sit 24hours per day to click on message boxes is plainly stupid.

I always thought IB was the advanced broker with a nice API, turns out that is not the case... :sweat:

There are so many hurdles in this industry. Thanks for removing as many as possible @Tomasz

Did you send report to support email? We can only look at problems when report is sent to us. We need the entire content of crash report (not the screenshot but the TEXT of the report that can be got using "Copy to Clip" button)