Setting Up Heroku

Heroku is a free cloud server where you can easily deploy a NodeJS Express App. When you create a project on Heroku, you will be given a git URL where you can push the server files to. The Heroku backend will run "npm install" to build the NodeJS Express App and then run "npm run start", thus deploying your App. Heroku will also provide you a https url that can be used as the webhook URL in your Trading View alert.

Setup

  1. Download files from the Github repository to your computer

    1. Sign up for a Github account

    2. Establish authentication to Github API

      • Windows

        1. download VSCode

        2. download the Github Pull Requests Extension

        3. Click Accounts (bottom left) > sign in with Github

      • MacOS

        1. Use VSCode, as above

        2. Alternatively, use a Personal Access Token

          1. Log into Github > Profile photo (top right) > Settings > Developer Settings (left menu, scroll down) > Personal access tokens > Tokens (classic) > Generate new token (top right) > Generate a new token (classic)

          2. Give name, expiration date, and scopes (for scopes, click "repo" checkbox)

          3. Click Generate token

          4. When you run git clone (Step 1.4), it will ask for a username and password. Use your Github username. For password, use the generated token.

          5. Cache token with git config --global credential.helper osxkeychain

            1. view cached credentials with echo url=https://github.com/git/git.git | git credential fill

    3. In your CLI, cd into where you want the “trading-view-automation” folder downloaded, then run git clonehttps://github.com/brianonchain/trading-view-automation.gitarrow-up-right

  2. Upload files to Heroku

    1. Create a Heroku account

    2. Create a new app on Heroku

      1. Go to New (top right) > Create new app

      2. Enter a name, choose region, and click Create app

    3. Install the Heroku CLI (linkarrow-up-right)

      1. verify installation with heroku --version

      2. heroku update // updates heroku CLI

      3. heroku login

        1. press any key to continue

        2. Web browser should popup prompting login

    4. cd into the "trading-view-automation" folder

    5. git remote add heroku https://git.heroku.com/example-app.git // adds a remote labeled "heroku", which is an alias for the url

      • find the https url in the your Heroku account > project page > Settings tab (top center). Look in the App Information category for the Heroku git URL

      • git remote -v // check if remote is added

    6. push files to Heroku git URL with git push heroku main

      1. macOS may show a prompt for additional authentication. If so, type "blank" into username field and enter API Key into the password field. You can generate API Key withheroku auth:token

    7. Code is uploaded if you see various logs appearing for 10-15s

  3. Set environment variables

    1. In your Heroku account, go to Settings > Config Vars > click Reveal Config Vars

    2. Enter the environment variables detailed in Setting Up Env Vars

  4. Copy the app URL and use it as the webhook URL in your Trading View alert or sendAlert.js

  5. To view logs, go to More (top right) > View logs

  6. Every time you need to update the Heroku remote

    1. git pull origin main // this pulls changes from Github repository

    2. git push heroku main // this pushes changes to the Heroku repository

  7. Set up Google Sheets to see successful or failed trades (see Setting Up Google Sheets)

  8. Set up Telegram to see successful or failed trades (see Setting up Telegram)

Test Setup

Send a Trading View alert or mimic one using sendAlert.js. Use the provided Heroku HTTPS URL (see Step 1.4) as the webhook URL.

Last updated