Setting Up Local Server
Table of Contents
Introduction
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.
Ngrok Introduction
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.
(Optional) HashiCorp Vault + EthSigner Introduction
With HashiCorp Vault + EthSigner, your private keys can reside in a software-protected environment, as opposed to residing in a .env file. See Setting Up HashiCorp Vault + EthSigner.
System Diagram

Setup Ngrok
Create an Ngrok account (https://ngrok.com/)
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
Install tmux and read the usage instructions
Create new tmux window named "ngrok" with
tmux new -s ngrokShould see a green bar on the bottom, indicating a tmux window
Start ngrok tunnel with
ngrok http http://localhost:8080copy the HTTPS URL and use it as the webhook URL in your Trading View alert
Leave tmux window with
ctrl + b, thendWhen needed, re-enter tmux window with
tmux attach -t ngrokIf you exit the tmux window (with
ctrl + b, thenx), the tunnel will close. To restart a new tunnel, runngrok 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).
Setup NodeJS App
Install Git and NodeJS on your local server (instructions below is for Linux Ubuntu)
Install NVM and NodeJS
sudo apt update// updates packagessudo apt install curl -y// installs curl if not yet installedcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bashCheck install with
nvm -v
nvm install --lts// install NodeJS "long-term support" versionCheck install with
node -v
Install Git
apt-get install gitCheck 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
Enterto accept default location to generate filesAt 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.comEnter 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 installAdd environment variables
create “.env” file and start editing it with
touch .env, thenvim .envpress
ito start editing. Use the environment variables detailed in Setting Up Env Vars
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.jsIt should say "listening on port 8080" or whatever PORT you input in the .env file
ctrl + b, then
d// leave tmux windowWhenever you need to re-enter the window (for example, to view logs), run
tmux attach -t nodejs
Setup Notifications (Google Sheet and Telegram)
Set up Telegram to see successful or failed trades (see Setting up Telegram)
Set up Google Sheets to see successful or failed trades (see Setting Up Google Sheets)
Test Setup
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 Test With sendAlert.js).
If Ngrok is set up, use the Ngrok HTTPS URL as the webhook. If not, use http://localhost:8080.
Last updated