TradingView

Learn how to use Gunbot to execute trades based on incoming email alerts.

TradingView is the most active social network for traders and investors. TradingView allows users to create and share technical analysis and advanced trading strategies on their interactive charts.

With the Gunbot TradingView add-on you can trade on alerts sent from custom strategies at Tradingview, completely managing your strategy at TradingView. Gunbot receives trade signals by e-mail and trades accordingly.

This is a paid add-on, availability depends on your license type.

Setup video

Before you start setting up your alerts, you need:

  • The IMAP data for the email address you receive alerts from TradingView on.

  • A Pro subscription at tradingview.com (works with trial too). Free accounts are limited to one alert.

This video was made for an older Gunbot version. The basic steps still apply.

Script used in example: Finn's Microprofit Strategy

Alert message contents

The alerts messages have to be in the following format in order for Gunbot to act on them. Alerts follow the same standardized pair syntax that also apply for normal Gunbot usage.

Trading limits can only be specifically defined in buy/long alerts, for other alerts or alerts without specified amounts, the limits as set in your TradingView settings apply.

Replace EXCHANGE with the name of your exchange.

For all spot exchanges

Alert message

Action

BUY_EXCHANGE_BTC-ETH

Buy ETH using BTC

BUY_EXCHANGE_BTC-ETH_0.1

Buy ETH using BTC with a trading limit of 0.1 BTC

SELL_EXCHANGE_USDT-BTC

Sell BTC for USDT

STOPLOSS_EXCHANGE_BTC-ETH

Sell ETH for BTC if stoploss is triggered

Alerts for margin trading

Alert message

Action

SHORT_EXCHANGE_XBT-USD

Short order for XBT-USD

LONG_EXCHANGE_XBT-USD

Long order for XBT-USD

SHORT_EXCHANGE_XBT-USD_amount

Short order for XBT-USD with a specified trading limit

LONG_EXCHANGE_XBT-USD_amount

Long order for XBT-USD with a specified trading limit

CLOSELONG_EXCHANGE_XBT-USD

Closes a long position for XBT-USD

CLOSESHORT_EXCHANGE_XBT-USD

Closes a short position for XBT-USD

Note about trading limits

On Bitmex, every setting related to trading limits for margin trading must be specified in contracts. On all other supported margin exchanges, every setting related to margin trading limits must be specified in amounts of quote currency.

To test alerts on Bitmex Testnet, you should write the alerts like this: LONG_BITMEXTESTNET_XBT-USD

TradingView settings

To run Gunbot with the TradingView add-on, the following are the only relevant settings. Normal Gunbot strategy and pair settings are not relevant and not used unless TV_GB is enabled.

Open the settings by going to Settings > TradingView.

Settings options for the TradingView add-on

Trading limits for buy orders are set in the configuration settings, optionally you can override these by specifying the trading limit in the alert message contents.

Orders placed by the TradingView add-on are placed as market orders to ensure they will get filled.

Be sure to add one pair for any exchange you want to execute alerts on.

This can be any pair, it will not be used by the add-on.

Gain

Description
Values
Name

Set a minimum gain in % that trades initiated by TradingView must comply to when TV_PROTECTION is enabled.

When TradingView sell alerts are sent that would have a lower gain than this value, Gunbot will not place the order. Use this to prevent selling at loss.

Only works for spot trading.

Values: numerical, represents a percentage.

Default value: 0.6

Parameter name in config.js: TV_GAIN

Trading Limit Buy

Description
Values
Name

This value defines the trading limit for each buy order placed through the add-on.

The default value of 0.002 would place orders of 0.002 BTC when used on a BTC-x pair.

When not using TV_PYRAMID, a sell alert will place a sell order for the full quote balance held.

Bitmex: enter the desired number of contracts

Other margin exchanges: enter an amount in quote currency

Values: numerical – represents an amount in base currency.

Default value: 0.002

Parameter name in config.js: TV_TRADING_LIMIT_BUY

Trading Limit Buy Pyramid

Description
Values
Name

This value defines the trading limit for each pyramid buy order placed through the add-on.

The default value of 0.002 would place orders of 0.002 BTC when used on a BTC-x pair.

Bitmex: enter the desired number of contracts

Other margin exchanges: enter an amount in quote currency

Values: numerical – represents an amount in base currency.

Default value: 0.002

Parameter name in config.js: TV_TRADING_LIMIT_BUY_PYRAMID

Pyramid

Description
Values
Name

Setting this to true enables pyramid trading, the amount for each pyramid order is defined by TV_TRADING_LIMIT_SELL or TV_TRADING_LIMIT_BUY_PYRAMID.

Values: true or false

Default value: false

Parameter name in config.js: TV_PYRAMID

Trading Limit Sell

Description
Values
Name

This value defines the trading limit for sell orders when TV_PYRAMID is enabled.

The default value of 0.002 would place orders of 0.002 BTC when used on a BTC-x pair.

Bitmex: enter the desired number of contracts

Other margin exchanges: enter an amount in quote currency

Values: numerical – represents an amount in base currency.

Default value: 0.002

Parameter name in config.js: TV_TRADING_LIMIT_SELL

Protection

Description
Values
Name

When set to true Gunbot will check if there is an overall profit before selling, as specified in TV_GAIN.

When set to false, Gunbot will execute all TradingView alerts without interfering with a custom strategy.

Only works for spot trading.

Values: true or false

Default value: false

Parameter name in config.js: TV_PROTECTION

Close all

Description
Values
Name

When enabled, an entire position will be closed upon receiving a close command - even if the position is bigger than the set trading limits.

Only works for Bitmex.

Values: numerical – represents an amount in base currency.

Default value: false

Parameter name in config.js: TV_CLOSE_ALL

Trading Limit Cap

Description
Values
Name

The maximum amount of base currency to be invested in a pair.

Only works for spot trading.

Values: numerical – represents an amount in base currency.

Default value: 0.0001

Parameter name in config.js: TV_TRADING_LIMIT_CAP

Stoploss Percentage

Description
Values
Name

Percentage below average bought price at which a sell signal should override TV_PROTECTION and sell in a stop-loss manner.

Values: numerical – represents a percentage.

Default value: 60

Parameter name in config.js: TV_STOPLOSS_PERCENTAGE

Trading Limit All-In

Description
Values
Name

When set to true, each buy order will use all available base currency balance.

Values: true or false

Default value: false

Parameter name in config.js: TV_TRADING_LIMIT_ALLIN

Retry Order

Description
Values
Name

Enable this when you have problems receiving multiple alerts.

Gunbot will retry processing orders for 15 minutes.

Values: true or false

Default value: false

Parameter name in config.js: RETRY_TV_ORDER

TV MVTS

Description
Values
Name

Sets a threshold for sell orders, If you own less than the set amount, sell orders will not be placed and the bot goes into buying mode again.

Values: numerical – represents the total value of a coins holdings in base currency.

Default value: 0.001

Parameter name in config.js: TV_MVTS

TV GB

Description
Values
Name

Enable this to run Gunbot strategies simultaneously with the TradingView add-on. This way buying and selling with Gunbot strategies or TradingView alerts can be mixed.

The IMAP listener needs to be enabled to use this option.

Values: true or false

Default value: false

Parameter name in config.js: TV_GB

TV Leverage

Description
Values
Name

For margin trading only. Sets the leverage for opening any position. Setting 0 places the order with cross margin, if your exchange supports cross leverage. Only use values supported by your exchange.

Values: numerical – between 0 and 100

Default value: 0

Parameter name in config.js: TV_LEVERAGE

TV Lending

Description
Values
Name

Sets the maximum acceptable lending rate when opening a position.

The default setting of 0.02 stands for 2% interest per day.

Only works on Poloniex.

Values: numerical

Default value: 0.02

Parameter name in config.js: TV_LENDING