Link Interactive Brokers to TradingView via Ngrok

This Docker, TradingBoat is designed to launch the Trading Robot, which converts TradingView Alerts to Interactive Brokers. Once you understand the component applications inside the Docker containers, you can launch them on your own server, if desired instead of using Docker

Background

In order to link TradingView alerts to interactive brokers, you can use the Docker solution available for this. You can find it at: GitHub - PlusGenie/ib-gateway-docker: Docker image with TBOT on TRADINGBOAT. I can call this Docker solution a TradingBoat

This Docker, TradingBoat is designed to launch the Trading Robot, which converts TradingView Alerts to Interactive Brokers. Once you understand the component applications inside the Docker containers, you can launch them on your own server, if desired instead of using Docker.

Key features of this Docker include:

Question

Once you launch the docker container for linking TradingView to Interactive Brokers using TRADINGBOAT, how do TraingView alert reach this docker container outside the network?

In the TradingView Alerts window, for example, you need to set the public end-point URL for the destination of the alert messages as follows:

So the Docker, TradingBoat, provides the public endpoint URL using Ngrok.

You can see the Ngrok in the red block in the following picture, facing the HTTP POST - WEBHOOK from TradingView on the leftmost in the picture.

The Architecture of TradingBoat

Who is in charge of running the NGROK?

how can the TradingBoat docker run this NGROK?

Well, it is down to Docker compose. The docker-compose of the Tradingboat is as follows


version: "3.4"

services:
  ib-gateway:
    restart: always
    container_name: tbot-on-tradingboat
    build:
      context: ./stable
    environment:
      TWS_USERID: ${TWS_USERID}
      ....
      ...
    ports:
      - "127.0.0.1:4001:4001"
      - "127.0.0.1:4002:4002"
      - "127.0.0.1:5900:5900"
      - "127.0.0.1:5000:5000"
    depends_on:
      - redis
      - ngrok

  redis:
    image: redis:7.0.10-alpine
    restart: always
    container_name: redis-on-tradingboat

  ngrok:
    image: wernight/ngrok:latest
    restart: always
    container_name: ngrok-on-tradingboat
    ports:
      - "4040:4040"
    environment:
      NGROK_AUTH: ${NGROK_AUTH:-}
      NGROK_PORT: ${NGROK_PORT:-}

Basically, this docker-compose file utilizes the three open-source docker projects

  1. Interactive Brokers Gateway Docker image with IB Gateway and IBC, this docker installs IB Gateway, IBC application and X11 VNC server
  2. redis official docker image: Redis Pub/Sub or Redis Stream are being used for Message broker between TradingView Alert messages to Interactive Brokers
  3. Ngrok docker: this docker file provides Ngrok.

As you can see in the docker-compose file above, you can see the Ngrok container running


ngrok:
    image: wernight/ngrok:latest
    restart: always
    container_name: ngrok-on-tradingboat
    ports:
      - "4040:4040"
    environment:
      NGROK_AUTH: ${NGROK_AUTH:-}
      NGROK_PORT: ${NGROK_PORT:-}


You can use NGROK_AUTH to pass the authentication code which you can get after signing up. you can visit Ngrok Website.

Once the TradingBoat Docker starts to run the container, you can see its public web addresses from the TradingBoat web interface as follows: Simply visit http://127.0.0.1:5000. You will see the following pages.

Home page of TradingBoat

And then click Ngrok Page, you will have the public URL as follows:

Ngrok Agent Inspect Web Page


You can keep it and then you are ready to use that URL for TradingView alert message’s destination.

The following pictures show how to set up Webhook URL in TradingView's Alert window using the Ngrok URL.

TradingView Alert Window

Of course, you can use NGINX instead of Ngrok, but you need to have your own domain so that you can use HTTP.

Conclusion

You have seen how to link TradingView Alerts to Interactive Brokers via Ngrok, using the Docker TradingBoat.

You can see the installation guide from GitHub - PlusGenie/ib-gateway-docker: If you install the docker, it will automatically pull the relevant source.

If you want to have a step-by-step guide, please refer to the Udemy tutorial. Udemy course available here: Link to Udemy Course.

Subscribe to TBOT on TradingBoat

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe