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:
- 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: a framework 🏗 for trading with tradingview webhooks! .
- 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 Ngrok 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
- Interactive Brokers Gateway Docker image with IB Gateway and IBC, this docker installs IB Gateway, IBC application and X11 VNC server
- redis official docker image: Redis Pub/Sub or Redis Stream are being used for Message broker between TradingView Alert messages to Interactive Brokers
- 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.
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: 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.