Futures and Options Trading Automation
Interactive Brokers futures
Setup guide · CME index futures · about 15 minutes

Automate Futures Trading on Interactive Brokers

Connect your IBKR account to Trader Frame through the Bridge, then build a bot that trades MES, MNQ, ES, NQ, YM or RTY from your signals. Six steps, on a paper account first, and no code.

Trader Frame connects to Interactive Brokers through the TraderFrame Bridge and IB Gateway, then the futures bot's trades fill the signal ledger one by one
The open MES position at Interactive Brokers moving from its entry to the take-profit target, +$150.00

Before you start

What you need, and how the pieces connect

Interactive Brokers takes no API key. A small program, the TraderFrame Bridge, runs next to IB Gateway on your computer and carries your bots' orders to it.

An IBKR account

Paper to start. Trader Frame labels paper and live everywhere, and the Bridge refuses a mismatch.

IB Gateway or TWS

Installed and logged in. IBKR Desktop will not work: it has no API.

A Mac or Windows computer

It stays on while your bots trade. Linux works too, with Python 3.10 or newer.

CME market data, for live

Paper trades on delayed quotes. A live account needs a real-time CME subscription in IBKR.

On your computer
Trader Frame
Your bots decide the orders
TraderFrame Bridge
Holds one token, carries orders
IB Gateway or TWS
Logged in, API turned on
Interactive Brokers
Your paper or live account

Your IBKR login and two-factor never leave your computer. The Bridge places orders only for commands Trader Frame queued for your account, and reports every fill back.

Step by step

From an empty account to a bot trading MES on paper

Do the steps in order. Each one ends with something you can see, so you know it worked before you move on.

01
Step 1 of 6

Add Interactive Brokers in Trader Frame

  • Open Brokers and press + Connect broker.
  • Pick Forex & stock, then Interactive Brokers, and press Continue.
  • Choose Paper. The Bridge checks which account Gateway is logged into and refuses a mismatch.
  • Press Get my Bridge token, then Copy. Keep the sheet open for step 4.

The token stays the same until you disconnect the account. Brokers › ⋯ › View Bridge token shows it again. Treat it like a password.

The Interactive Brokers connect sheet in Trader Frame: Paper or Live, the Bridge downloads, and the steps to run on your computer
02
Step 2 of 6

Turn on the API in IB Gateway

  • Install IB Gateway from Interactive Brokers (Trader Workstation works too) and log in to your paper account.
  • Open Configure › Settings › API › Settings.
  • Tick Enable ActiveX and Socket Clients, untick Read-Only API, and add 127.0.0.1 to Trusted IPs.
  • Apply, and leave Gateway running and logged in.
Without this the Bridge cannot talk to Gateway: its window says “Not reachable”.
IB Gateway · API settings
Configure › Settings › API › Settings
Enable ActiveX and Socket Clients
Ticked
Read-Only API
Unticked
Trusted IPs
127.0.0.1
Socket port
left as it is
Port the Bridge looks for
Paper
Live
IB Gateway
4002
4001
Trader Workstation
7497
7496
03
Step 3 of 6

Install the Bridge and paste your token

  • Mac: download the Bridge from the connect sheet, unzip it and open the app.
  • Windows: run the installer. If Windows says “unknown publisher”, choose More info, then Run anyway.
  • Linux: the Python version, unzipped; double-click start.command.
  • Paste your Bridge token and press Connect. It finds Gateway on its own, paper or live, and remembers the token.
The TraderFrame Bridge window connected: IB Gateway on port 4002, TraderFrame checked in, a paper account and delayed market data
04
Step 4 of 6

Check that the account is connected

  • Back in Trader Frame, press I've done this. The sheet listens for the Bridge.
  • Within about 20 seconds the Bridge checks in and the account arrives with its balance.
  • In Trader Frame the account card reads Bridge online, with the account, its balance and the Bridge version.
  • Bridge online · delayed data is normal on paper. Live trading needs real-time data (see Market data).

If a newer Bridge is out, the card shows an Update link. Download again and replace the app; your token stays.

The account cards on the Brokers page, with the Interactive Brokers card reading Bridge online, delayed data, and the Bridge version
05
Step 5 of 6

Build a futures bot

  • Create a bot and pick the Interactive Brokers account as its broker.
  • In Position size, set Instrument to Futures and pick the product, for example MES.
  • Keep Front month, auto-roll. New entries move to the next month three trading days before expiry.
  • Set whole contracts per signal, the entry (Bracket is the default) and the session: regular 09:30–16:00 New York, or extended.
  • Press Save order.

Flatten at 15:55 is on by default: no new entries after it, and open positions close. Turn it off for swing bots.

The futures order panel: MES Micro E-mini S&P 500, front month auto-roll, one contract, bracket entry
06
Step 6 of 6

Set the exits, add a signal, switch it on

  • In Exit rule, set stop and target in points, ticks, ATR or dollars, and an optional move to break-even. Press Save exit.
  • Open the Trading View source, copy the webhook URL and the alert message, and paste both into your TradingView alert.
  • Press Activate. Watch the Signals tab for the first alert and the Trades tab for the fill.

Stop and target go to IBKR with the entry, so they hold even if the Bridge or your computer goes offline.

The futures exit panel: stop 20 points and target 30 points, $100 and $150 on one contract

The alert message

The message only says buy or sell. Size, contract month and exits come from the bot.

TradingView alert message · strategy
Copy it from the bot's TradingView panel
{ "symbol": "{{ticker}}", "side": "{{strategy.order.action}}" }
Indicator alerts · one per side
Buy and Sell
{ "symbol": "{{ticker}}", "side": "BUY" }
{ "symbol": "{{ticker}}", "side": "SELL" }

The alert names the product any way a chart does: MNQ, MNQ1!, CME_MINI:MNQ1! or MNQZ6 all reach an MNQ bot. The contract month is always the bot's choice, never the alert's.

Market data

Delayed on paper is fine. Live needs real-time CME data.

Real-time CME data is a subscription in your IBKR account, not something a live account has by itself. While the feed is delayed, quotes and the Trade Agent's bars are 15 minutes old; fills still happen at the live price.

Subscribe in IBKR Client Portal
Settings › Trading Platform › Market Data Subscriptions › the CME real-time bundle.
For the same data on paper, turn on sharing market data with your paper account there.
Account
Data feed
What the bot does
Paper
Delayed
Trades. The account shows a Delayed pill.
Live
Delayed
Refuses entries: “Live entries need real-time data”.
Live
Real-time
Trades.

Keeping it running

Day to day with the Bridge

The daily log-in

IB Gateway asks you to log in again once a day, and to re-authenticate fully once a week. Until you do, the account reads Needs your login and your futures bots pause. Stops already at IBKR stay in place. Log in and the Bridge reconnects on its own.

Keep the window open

The Bridge works while its window is open and Gateway is logged in. One Bridge per IBKR account, on one computer.

Updating the Bridge

When a newer Bridge is out, the account card shows an Update link: download again and replace the app (Mac: drag the new app over the old one; Windows: run the installer). Your token and settings stay.

Closing by hand and holidays

Close now sends a market order through the Bridge and cancels the stop and target at IBKR. Outside CME hours, and on early-close holidays when index futures halt 13:00–18:00 New York, IBKR holds the order until the reopen.

Troubleshooting

What a message means, and what to do

Every refusal and skip is written to the bot's Signals tab with its reason, so you can see why a signal did not trade.

What you see
Why
What to do
Bridge: IB Gateway “Not reachable”
Gateway is closed, logged out, or its API is off.
Start Gateway, log in, and redo step 2.
Bridge: “Token rejected”
The token was copied wrong, or the account was disconnected.
Copy it again: Brokers › ⋯ › View Bridge token.
Refused: “Market closed for this bot”
The signal came outside the bot's session.
Switch the bot to extended hours to trade the overnight session.
Refused: “Not enough buying power”
The size needs more margin than the account has, with a 20% cushion.
Fewer contracts, or the micro product (MES, MNQ).
Refused: “Live entries need real-time data”
A live account on a delayed feed.
Subscribe to CME real-time data in IBKR.
Refused: “The Bridge is offline or IB Gateway needs your login”
The Bridge window is closed, or Gateway logged out.
Open the Bridge, or log Gateway back in.
Skipped: “Symbol mismatch”
The alert named a different product than the bot trades.
Point the alert at the right bot, or change its product.
Limits
One Bridge per IBKR account, on one computer
Individual accounts only: not linked or advisor accounts
The six CME index futures: MES, MNQ, ES, NQ, YM, RTY

FAQ

Interactive Brokers futures questions

Do I have to leave my computer on?

Yes, while your bots trade: the Bridge and IB Gateway run there. If it goes off, stops and targets already at IBKR stay in place, and new signals wait until the Bridge is back.

Can I use Trader Workstation instead of IB Gateway?

Yes. Turn on the same API settings in TWS. The Bridge finds either one on its own. IBKR Desktop has no API and does not work.

Does Trader Frame see my IBKR password?

No. You log in to IB Gateway yourself, with your two-factor. Trader Frame only ever holds the Bridge token.

Which contract month does the bot trade?

The front month, rolled three trading days before it stops trading. You can pin one month instead. The alert never decides the month.

Why are prices late on my paper account?

Most IBKR accounts start with delayed data, 15 minutes behind. Fills still happen at the live price. Share a CME subscription with paper to see real-time quotes.

What about options on Interactive Brokers?

Options bots use the same Bridge and connection. The IBKR options guide covers the contract rule, filters and exits in premium.

Start on a paper account

Prove it on paper. Go live when it has earned it.

Switching to live is the same bot on your live IBKR account, with a real-time CME subscription. Nothing else changes.