Webhook alerts
Using webhooks, alerts from TradingView.com can be sent directly to a Gunbot instance. You need to be able to run Gunbot on a device that is publicly accessible on port 443.
Webhook URL: https://[Your_Gunbot_IP]:443
Initial setup for TradingView Bot​
Before you start setting up your alerts to create a TradingView Bot, you need to:
- Make sure your system has LibreSSL installed, this will generate the needed certificate
- Make sure your device is publicly accessible on port 443, the only port allowed by TradingView
- Enable webhooks support in Gunbot on the TradingView settings page and set a self chosen passphrase to use in alerts, to ensure it is you who sends the alerts that the trading bot will execute
- Like with TradingView alerts in email mode, make sure to add one valid pair to Gunbot for each exchange you'll receive alerts on. This pair will not get actively traded unless you send alerts for it.
Use with or without pair cycling​
If you want Gunbot to purely execute incoming webhook alerts, then disable TV_GB
and make sure that alerts contain the needed price / amount info to place the intended orders.
If you want to use Gunbot data to for example protect profits using TV_PROTECTION
, then enable TV_GB
and add all pairs to your Gunbot config, for which you expect alerts for.
Easy way to generate valid alerts​
The trading settings page offers a configurator to create alert trading scenarios, it's easiest to use this option and use the exact alerts it generates.
These generated alerts contain the following elements:
- Password: Used for authentication, ensuring that only authorized users or systems can trigger actions.
- Exchange: Specifies the exchange where the action should occur.
- Alert Type: Identifies the type of alert, allowing you to differentiate between various events.
- Pair: Specifies the target trading pair .
- Amount: Indicates the quantity or size of the order to be executed.
- Price: You can set a specific price or a placeholder like {{close}}. When a price is specified, the order gets placed as limit order. When price is set as 0, then the order gets placed as a market order.
- Current Alert Number: Helps keep track of the number of alerts triggered for the same alert type.
By configuring multiple alerts before taking action, you can create multi-condition strategies without worrying about the order in which the alerts occur. This flexibility allows for sophisticated trading strategies that respond to a combination of market conditions. As an illustration, one alert might be linked to an EMA (Exponential Moving Average) condition, another tied to an RSI (Relative Strength Index) condition, and a third associated with a supertrend condition. These alerts can trigger independently and in random order.
Your trading strategy isn't restricted to these generated alerts. You have the freedom to incorporate additional alerts for example with different order amounts.
For further information on utilizing variables in alerts, such as {{close}}, you can refer to the TradingView documentation.
Example of generated spot alerts​
Buy alerts:
123456asdfsaf mex_gunthy customlong BTC-ETH 2 0 1
123456asdfsaf mex_gunthy customlong BTC-ETH 2 0 2
// configured to require 2 alerts before buy is placed, market buys 2 ETH at a time
Sell alert:
123456asdfsaf mex_gunthy customshort BTC-ETH full 0 1
// configured to require 1 alerts for selling, market sells full ETH amount
When using generated alerts, ensure also using the strategy settings as saved to config.js when using the webhooks editor. There are several required settings for handling the expected number of alerts of the same type.
Alert message contents​
Alternatively, you can create alerts using this format:
passphrase exchange order_type pair amount price
Alerts follow the same standardized pair syntax that also apply for normal Gunbot usage, the alert text must be in the subject line of an email. This format requires no special strategy settings.
Limit order alert examples​
spot:
123456 binance buy USDT-BTC 0.1 42553.4
123456 binance sell USDT-BTC 0.1 42553.4
futures:
123456 binanceFutures long USDT-BTC 0.1 42553.4
123456 binanceFutures short USDT-BTC -0.1 42553.4
123456 binanceFutures close USDT-BTC 0.1 42553.4
123456 binanceFutures close USDT-BTC -0.1 42553.4
Market order alert examples​
spot:
123456 binance buy USDT-BTC 0.1 0
123456 binance sell USDT-BTC 0.1 0
futures:
123456 binanceFutures long USDT-BTC 0.1 0
123456 binanceFutures short USDT-BTC -0.1 0
123456 binanceFutures close USDT-BTC 0.1 0
123456 binanceFutures close USDT-BTC -0.1 0
Change strategy alert​
format:
passphrase exchange strat pair name_of_strategy_here 0
example:
123456 okgunbot strat ETH-AVAX superCoolDCA 0
Other settings​
Currently a small subset of the settings available for email alerts are available for use with webhooks:
- TV_GB
- TV_PROTECTION
Installing LibreSSL on Windows​
If you get certificate related errors when enabling the webhook listener on a windows server, the following steps should resolve it.
open powershell and run the following command:
Set-ExecutionPolicy Bypass -Scope Process
still in powershell, run the following command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
open cmd terminal and run this command to install libressl:
choco install -confirm libressl
In case errors persist, manually install LibreSSL using this method:
- download .dll from here https://sourceforge.net/projects/libressl-3-2-0-for-windows/files/LibreSSL-3.3.3_MinGW_Windows7%28static%29.zip/download
- extract the folder in c:/libressl