Automated Trading » Overview


Wouldn't it be great if instead of you manually acting on alert messages and opening/closing positions yourself, you could instruct the strategy to open/close trades automatically on your behalf?

Unfortunately, TradingView does not allow strategy scripts to execute trades directly on the chart, however with a bit of help we can connect the strategy to a real exchange where your orders can be executed.

Exchanges usually don't provide a way for TradingView strategies to send messages to them directly (with a few exceptions).

Script direct connection to exchange

What we need to do instead, is to use an intermediary service (such as Alertatron) that accepts messages from TradingView scripts. Once this intermediary service receives a message from a TradingView script, it translates the message into an exchange specific format, which they forward onto the exchange.

Script using intermediary connection to exchange

The reason for this, is that TradingView scripts can only send webhook messages to the outside world, and very few exchanges accept webhook messages.

Several companies realising this gap, they set out to offer a web service that accept webhook messages from TradingView alerts, and in turn they communicate with the exchange via their own custom exchange-specific API.

Some example of companies offering alert forwarding services:

A word of caution

If you decide to link your TradingView alerts to a 3rd party service, like 3Commas, please read the following article to understand the risks that come with connecting two platforms together: https://web.archive.org/web/20230331120200/https://backtest-rookies.com/2020/01/11/stay-in-sync-tradingview-3rd-party-services/

In a nutshell, the problem is that it is not 100% that your alerts from TradingView will always reach your 3rd party trading platform, which can result in monetary loss for you. Imagine that the strategy signals a long entry, successfully notifies the 3rd party platform, a position gets opened (on the 3rd party platform), but when the strategy decides it’s time to close the position and sends a "close" position alert to the 3rd party, if their servers are momentarily down, your request to exit the strategy is lost, leaving your position open for longer than necessary. On top of this, the strategy running on TradingView is now in the belief that you have no open position (it has no idea that the 3rd party didn’t receive your alert), so the next time an opportunity comes to open a position, it will send an alert to the 3rd party, potentially resulting in you now having two open positions instead of one.

Because of this, please make sure that you keep an eye on the alerts coming from TradingView, and make sure that those alerts are processed by the 3rd party, and if not, act on the alert manually. If the strategy and the 3rd party platform got completely out of sync, it is better to delete the alert, close out any open positions on the 3rd party, and create a new alert.