NinjaTrader Connection Guide for Interactive Brokers
- Interactive Brokers valid account
- Account user name and password
- You must have standalone Traders Workstation (TWS) version 938.1 (browser version is not supported) installed - Download
Connection Configuration Instructions
- NinjaTrader must be installed
- Start Interactive Brokers TWS
- When using the Mosaic interface, the Advanced Order Management (TWS) window must be open to both configure the connection and connect with NinjaTrader. As per the image below, select "New Window> Advanced Order Management (TWS)"
- As per the image below, select the menu "Edit > Global Configuration…"
- As per the image below, enable the following options
- Enable ActiveX and Socket Clients
- Download open orders on connection
- Include FX positions when sending portfolio
- Send status updates…
- Set the "Socket port" value to 7496
- Start NinjaTrader
- From the Control Center window, select the menu "Tools > Account Connections…"
- In the Account Connection Set Up window, press the "Add…" button
- The Connection Wizard will appear. Press the "Next >" button.
- As per the image below
- Connection name: Create a name to identify your connection
- Provider: Select "Interactive Brokers" from the list
- Backup data feed connection: Select your backup datafeed or leave as "<None>"
- Connect on startup: Enable if you want NinjaTrader to automatically establish a connection on startup
- Select "Use Interactive Brokers servers" for historical data or disabled if you will be using a different connection for historical data
- Press the "Next>" button
- As per the image below enter your Interactive Brokers account logon
- User name: Your Interactive Brokers account user name
- Password: Your Interactive Brokers account password
- Host: Leave this as "localhost" unless you want to connect NinjaTrader to TWS running on another PC within your local area network. If connecting over a network enter the computer name or IP address.
- Port: Ensure that this value is set to the same value in TWS (step 4 above)
- Client ID: Leave this set to a value of zero "0" unless otherwise instructed by a technical support representative
- Trigger after hours: Enable this if you want stop orders to trigger outside of standard trading hours. This will only work if you also have "Allow order to be activated, triggered, or filled outside of regular trading hours" enabled in TWS (Configure > Order > Order Presets > Timing menu)
- Auto logon: Enables NinjaTrader to automatically start and log on to TWS
- Run-time pop up handling: Enables NinjaTrader to suppress TWS pop up windows
- SSL: Enable secure socket layer
- Local OCO simulation: Enables NinjaTrader to handle OCO (one cancels other order handling) on your local PC. DO NOT enable this unless otherwise instructed by a technical support representative
- Use user settings: Enables NinjaTrader to use TWS user settings when automatically started
- Trade Currencies (FX): Enable this if you trade currencies (forex) through your Interactive Brokers account
- Press the "Next >" button followed by the "Finish" button to complete configuring your Interactive Brokers account.
- If you will be trading currencies (forex):
- You must set the correct setting for the "Quote currencies (FX) in:" property accessible from within the NinjaTrader Control Center window menu "Tools > Options > Data".
- Set the value to HalfPip
- Critical: The forex positions reported in NinjaTrader are based on the positions reported in TWS FX Trader and the FX Portfolio section of the TWS Account window. This is NOT the cash value reported in the Market Value section of the TWS Account window.
- To connect to your account, go to the NinjaTrader Control Center window, select the menu "File > Connect" and select your account.
- If you run into any problems connecting to your account, please review the common problems and resolutions below
Common Problems Connecting to your Interactive Brokers Account
Always check the Control Center Log tab to see if there are any connection error messages.
I try to connect but nothing happens
This is usually because TWS is not configured correctly. Please review step 3 above.
I see an error message "Target machine actively refused…"
If you have another 3rd party application connected to TWS, ensure that it is not using a Client ID value of zero. Try shutting down this application and then connecting NinjaTrader to TWS.