![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Connecting Support for establishing connections to your broker or market data service provider. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Posts: 584
Thanks: 2
Thanked 21 times in 12 posts
|
Hello to the Ninja Team and good morning,
I continue to have connection problems with IB in certain cases and I get the infamous message IB: No connection could be made because the target machine actively refused it. There are numerous posts concerning this message! I have traced down the problem and I quite firmly believe that this is a bug of the Ninja IB adapter. Here my findings: The content of the message makes sense: It means that TWS is already connected to Ninja and therefore a second connection is refused. Can TWS already be connected to TWS? Yes it can and the typical case is that you have two or more IB accounts and one of them is already connected. The IB adapter will then - erroneosly - take the running instance of TWS for good and will try to connect. But it will fail since the other IB connection is already there. Here a fix proposal for your software guys: Please check - when you get that message or always- wether there is another TWS connection already made in case you find the TWS application running. If you find another IB connection open then please load a new TWS instance instead and connect to the new TWS instance. for example (pseudo-code) ConnectToTWSAdapter(){ List<Connection> connections=FindAllActiveConnections(); List<TWSInstance> twsInstances = FindAllRunningIstances(TWS); List<TWSInstance> twsAvailable=new List<TWSInstance>(twsInstances); // create a copy to work on foreach(Connection c in connections){ if c.Adapter==IB && c.IsConnected) { twsavailable.Remove(c.twsInstance); } } TWSInstance useMeTWS=null; if(twsAvailable.Count>0) useMeTWS=twsAvailable[0]; if(useMeTWS==null) { useMeTWS=LoadNewTWSInstance() } connectToInstance(useMeTWS); } I would welcome if your developers could revise the IB adapter logic and hopefully the above suggestions are useful and appreciated. Best regards Andreas
Last edited by zweistein; 06-29-2009 at 03:04 AM.
Reason: better code
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
>> The IB adapter will then - erroneosly - take the running instance of TWS for good and will try to connect.
This is not an error but works as expected: NT will try to connect to a running TWS instance.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2009
Posts: 584
Thanks: 2
Thanked 21 times in 12 posts
|
Yes, but your approach is a bit simplistic:
You must differenciate the tws running instances between running tws instrances already connected and those not connected. For a new connection you must use a running TWS instance not yet connected. Otherwise your error will always show up when you try to connect automatically to a second IB . Current solution is to load the second TWS manually. Remember that you offer MultiBroker licenses and I expect you to have your logic revised for this. Best regards
Last edited by zweistein; 06-29-2009 at 03:34 AM.
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Thanks for your suggestion. We'll add it to the list of future considerations.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Junior Member
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Dear Admin, I also have the same problem of connecting to IB. actively refused by IB TWS. It keeps saying that every single time no matter I have TWS running or not. Does anyone actually has NinjaTrader working with latest TWS? Thanks |
|
|
|
|
|
|
#6 | |
|
NinjaTrader Customer Service
Join Date: Jul 2008
Location: Denver, CO, USA
Posts: 1,828
Thanks: 4
Thanked 19 times in 18 posts
|
Quote:
Thank you for your post. The "latest TWS" is NOT supported by NinjaTrader 6.5. Please downgrade to TWS 892.7 from here: http://www.ninjatrader.com/webnew/su...ivebrokers.htm
Ray S
NinjaTrader Customer Service |
|
|
|
|
|
|
#7 | |
|
NinjaTrader Customer Service
Join Date: Jul 2008
Location: Denver, CO, USA
Posts: 1,828
Thanks: 4
Thanked 19 times in 18 posts
|
Quote:
Thank you!
Ray S
NinjaTrader Customer Service |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FIX adapter | nicko9 | Connecting | 9 | 01-19-2011 03:52 PM |
| Login Failed.IB. Adapter.MessageLoop | Razorin | Connecting | 6 | 03-25-2009 02:50 PM |
| IB adapter bug - can not run live | heech | Connecting | 12 | 03-25-2009 02:56 AM |
| Login failed - target machine actively refused it | MarkSanDiego | Installation and Licensing | 3 | 11-26-2008 04:14 AM |
| IB Adapter optimisation queries | Aussie2 | General Programming | 2 | 03-04-2008 03:40 PM |