TradingView.com provides powerful charting and indicator tools to create robust trading strategies. However, it does not allow automated trading.
Autoview is a chrome extension that bridges the gap between TradingView.com Charts and your exchange and executes trades automatically based on Alerts you program in TradingView.com Charts.
This project aimed at solving the problem of running a bot locally which does not work when the computer is off. A server was needed, and so I created this Docker image to enable myself and anyone to easily fire up a new container that runs Autoview as a service.
While I could have used a Windows VPS and set it up easily through remote desktop, I did not think of it before creating this, and so I created an Ubuntu 16.04 Docker image with an X-server installed and a VNC server to enable VNC connections (remote desktop). It works perfectly at running Autoview as a service and is easy to setup, only a couple simple steps.
- Create an Unbuntu 17.10 server with at least 2GB RAM
- Run
sudo apt update && sudo apt upgrade
to update all dependencies - Install Docker and Docker-compose.
To use the pre-compiled Docker Image:
- Login via SSH to your server
- Run
docker pull iamtheiam/autoview-bot
. This will pull the image from the public docker repository I created - Follow the steps in Deployment and Startup.
To build the image from source:
- Run
git clone https://github.com/IAMtheIAM/autoview-tradingview-chrome-docker-bot.git
: - Run
npm install
- Run
npm run build:docker
- Upload the docker image to your server either via Dockerhub or SSH, see instructions:
- (From your local machine)
docker save autoview-bot:latest | bzip2 | pv | \ ssh user@host 'bunzip2 | docker load'
- (From your local machine)
- Follow the steps in Deployment and Startup.
-
Upload
docker-compose.yml
andlaunch-virtual-display.sh
to your server. NOTE 1: The default VNC password isyourpassword
- you should change this indocker-compose.yml
to a secure password. NOTE 2: By default it runs onport 3903
for security. You can change this to any port you want inside./launch-virtual-server.sh
on line 82. -
From that same directory, run
sudo docker-compose up
-
Connect to your Docker container through VNC Viewer.
-
Right click on the Desktop > Applications > Shell > Bash
-
OPTIONAL: To automate logging in to TradingView.com,
nano bot.ts
and enter your username and password on lines 3 and 4. NOTE: The automation library this script depends on isChromeless
, which sometimes acts funny and doesn't open the browser tabs correctly. Just manually opentradingview.com
andlocalhost:9222
if this happens. -
Manually setup your Autoview credentials like normal in the extension options (click the Autoview extension icon and go to Settings). OPTIONAL: To automate adding API credentials into Autoview,
nano bot-setup.ts
and customize the script for the exchanges you will use and your API keys. Then runnpm run setup
to run the Autoview setup script (and load the Autoview extension automatically). Delete thebot-setup.ts
script when you are done withrm bot-setup.ts
-
Run
npm run start
to run load Chrome with the Autoview extension automatically installed. If you did not enter your username and password intobot.ts
, you will need to manually enter it when the login screen automatically appears after a few seconds (the bot will click login for you). -
Within tab
localhost:9222
, click the one that says Autoview. Now you can see the debugging output for autoview to see if its working. -
Setup your TradingView.com alerts and watch them get triggered automatically 24/7!
-
OPTIONAL, but strongly recommended: Install a strong firewall with bruteforce detection
apt install apf-firewall
To install BFD, see: http://www.webhostgear.com/60.html
Configure your ports as desired. It is strongly suggested to run your VNC on a non-standard port for security purposes
If you have any tips or suggestions for improvement, or constructive critisism, open an issue ticket here on GitHub and I will respond to you soon.
Note: I have recently switched to using Gekko Bot for automated trading, as it is not dependent on TradingView.com alerts in any way, and therefore, significantly more reliable. It is written in JavaScript, which was a plus for me. The downside is that you have to recreate your PineScript strategies from scratch in JavaScript (although it's pretty easy to do). However, the setup demonstrated here in this repo still works just fine, you will just want to monitor your VM and make sure the browser doesn't crash or get disconnected from TradingView, which can happen if you open your chart on multiple devices.