Using Docker-Compose for TradingView Alerts Integration with Interactive Brokers

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.

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:

  • It utilizes the ib_insync API, providing a web interface, along with Discord and WhatsApp messaging app support.
  • Internally, this Docker pulls from more than two repositories, the key ones being: GitHub - PlusGenie/tbot-tradingboat and

GitHub - PlusGenie/tradingview-webhooks-bot: Converting TradingView PineScript Alerts into Interactive Brokers Orders

  • It supports various order types including market, stop, limit, stop-limit, bracket, and attached orders.
  • The specialized PineScript library is used to generate a pre-defined JSON format: PineTradingbotWebhook — Library by AlphaCentauri66367 .
  • All sources are open and can be accessed directly.

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 Ngroj in the red block in the following picture, facing the HTTP POST - WEBHOOK from TradingView on the leftmost in the picture.

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

GitHub - PlusGenie/ib-gateway-docker: Converting TradingView PineScript Alerts into Interactive Brokers Orders , this docker installs IB Gateway, IBC application and X11VNC server

2. redis official docker image:redis - Official Image | Docker Hub

  • Redis Pub/Sub or Redis Stream is being used for Message broker between TradingView Alert messages to Interactive Brokers

3. The official Ngrok Docker: https://hub.docker.com/r/ngrok/ngrok

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


ngrok:
    image: ngrok/ngrok:3
    restart: always
    container_name: ngrok-on-tradingboat
    command:
      - http
      - "${NGROK_PORT}"
    ports:
      - "4040:4040"
    environment:
      NGROK_AUTHTOKEN: ${NGROK_AUTH}
      NGROK_REGION: us
      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.

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


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.

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:https://github.com/PlusGenie/ib-gateway-docker If you install the docker, it will automatically pull the relevant source.

For further details and procedures, I highly recommend referring to the comprehensive 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