Setting Up Local Server
Last updated
Last updated
For your local server to receive webhooks from Trading View, it must have a SSL/TLS address. This can be done in three ways:
Getting a static IP from your ISP and creating a TLS certificate
Registering a domain
Using a reverse proxy, such as Ngrok
Using a reverse proxy is the easiest and we'll detail the use of Ngrok in this documentation.
With Ngrok, you will be given a TLS-secured HTTPS URL, which can be entered into the "webhook URL" field in your Trading View alert. When the JSON message is sent to the Ngrok URL, it is forwarded to your local server through a continuously persistent, TLS-secured tunnel. If your server temporarily disconnects from the internet, the Ngrok tunnel should automatically re-establish when your internet reconnects.
Install Ngrok agent and add Auth Token (do this once)
In your Ngrok account, go to Setup & Installation (left menu)
At the top of the page, select Linux and follow the on-screen instructions
Install Ngrok via Apt with:
Add auth token to ngrok.yml configuration file with: ngrok config add-authtoken <authToken>
Console should show "Authtoken saved to configuration file: /home/<user>/.config/ngrok/ngrok.yml"
Run the Ngrok client in a new tmux window
Create new tmux window named "ngrok" with tmux new -s ngrok
Should see a green bar on the bottom, indicating a tmux window
Start ngrok tunnel with ngrok http http://localhost:8080
copy the HTTPS URL and use it as the webhook URL in your Trading View alert
Leave tmux window with ctrl + b
, then d
When needed, re-enter tmux window with tmux attach -t ngrok
If you exit the tmux window (with ctrl + b
, then x
), the tunnel will close. To restart a new tunnel, run ngrok http http://localhost:8080
. A new HTTPS URL will be given, so you will have to replace the old URL in all your Trading View alerts. This can be inconvenient, so do not close the tmux window (the terminal window can be closed). Alternatively, you can register for a static HTTPS URL on Ngrok (paid plan).
Install Git and NodeJS on your local server (instructions below is for Linux Ubuntu)
Install NVM and NodeJS
sudo apt update
// updates packages
sudo apt install curl -y
// installs curl if not yet installed
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Check install with nvm -v
nvm install --lts
// install NodeJS "long-term support" version
Check install with node -v
Install Git
apt-get install git
Check install with git --version
Create SSH link to Github (on your personal computer, your OS credential manager can help authentication, so the "https method" can be used; whereas, on Linux, we must use the "ssh method")
Generate ssh public/private key
In CLI, run ssh-keygen -t ed25519 -C "your_email@example.com"
use your Gitub email
press Enter
to accept default location to generate files
At prompt, enter a passphrase (can be anything)
You may need this to re-login every now and then, so note it down somewhere safe
Reenter the passphrase
Two files will be generated the ~/.ssh folder: "id_ed25519" (the private key) and "id_ed25519.pub" (the public key)
Copy the public key
cd into ~/.ssh folder and run cat id_ed25519.pub
// this prints the key to console. Copy the entire key (including email)
Log into Github > click profile icon (top right) > Settings > SSH and GPC Key (left menu) > New SSH key
Give key a name
Purpose is “Authentication Key"
Paste copied public key into the key field (paste the entire string, including the email)
Click “Add SSH Key”
Verify setup
In CLI, run ssh -vT git@github.com
Enter passphrase (that you chose above) when prompted
Download the NodeJS App from the Github repository
cd into the folder where you want the “trading-view-automation” folder downloaded
run git clone git@github.com:brianonchain/trading-view-automation.git
Prepare the environment
cd into “trading-view-automation” folder
install modules listed in package.json with npm install
Add environment variables
create “.env” file and start editing it with touch .env
, then vim .env
Run server.js in tmux window
cd into "trading-view-automation" folder
tmux new -s nodejs
// creates tmux window called "nodejs"
new terminal interface with green line on bottom should appear
node server.js
It should say "listening on port 8080" or whatever PORT you input in the .env file
ctrl + b, then d
// leave tmux window
Whenever you need to re-enter the window (for example, to view logs), run tmux attach -t nodejs
If Ngrok is set up, use the Ngrok HTTPS URL as the webhook. If not, use http://localhost:8080
.
With HashiCorp Vault + EthSigner, your private keys can reside in a software-protected environment, as opposed to residing in a .env file. See .
Create an Ngrok account ()
and read the
press i
to start editing. Use the environment variables detailed in
Set up Telegram to see successful or failed trades (see )
Set up Google Sheets to see successful or failed trades (see )
The cloned Github repo above contains a "sendAlert.js" file that allows you to send a mock Trading View Alert JSON message the NodeJS App (see ).