Tradingview: Configuring alerts & making the right choice

Configuring alerts on Tradingview can seem like a simple task at first glance. However, if you plan on using the alert system with a 3rd party service for automation, picking the wrong alert option can seriously impact your performance. In this article we will discuss the various alert options and which ones are best suited to your strategy.   

Configuring Alerts

When setting up alerts, it is important to select the correct “option” for each type of alert. The options in question are “Only Once”, “Once Per Bar”, “Once Per Bar Close” and “Once Per Minute”. Of these, you will mostly use only “Once Per Bar” and “Once Per Bar Close” and selecting the right one will depend on what order your strategy is trying to emulate.

Market Orders

A screenshot of the alert wizard in tradingview showing

In backtesting, Market orders are sent after the bar closes and fill at the open of the next bar. So naturally, the ideal option to select in this case is “Once Per Bar Close”. This ensures that the signal is confirmed before sending an entry order. Otherwise, when you have live data and the indicator moving with every tick (repainting) you might end up firing an alert mid bar only for the price to reverse. With “Once Per Bar Close” you should enter your position some time near the open of the next bar.

It is important to note that in the real world, your order will very rarely be executed at the same price as the open level of the following bar. However, this method will be as close to the open as you can reasonably expect. The reason for this is that there are a lot of actions that need to happen. In the real world these all take some time.

For example, first, your alert needs to be triggered by Tradingview. They then fire off an HTTP request to the server of your choice (assuming you use webhooks). Next, the third-party service then needs to process the request and translate it to an order. Finally, the third-party service then needs to make a request to the exchange to place that order. None of this is instant and it can take some time. Especially when the 3 parties are in different corners of the world.

Stop and Limit Orders

A screenshot of the alert wizard in tradingview showing

For reasons outlined in the article It is not recommended to use real stop or limit orders with 3rd party services. This is because it is likely you will lose sync with the real world. For a full explanation, click through to that article.

So when configuring alerts to mimic a stop loss or take profit, it is better to trigger a market order as soon as the stop or limit level is touched by price. In other words, whenever you see a purple exit marker in your strategy at a given level, we simulate that by triggering an alert as soon as that level is hit.

IMPORTANT: Only do this if you know what you are doing and understand the risks. By using market orders, you will gain the benefit of your script staying in sync with the real world. However, you will not have a real order in the market. Therefore, you could end up with greater losses than expected.

To set up for stop and limit orders, you should configure your alerts to use the “Once Per Bar” setting. This will allow the alert to be triggered mid-bar (when you have live data!) and take you out of the position as close to the stop loss level as possible.

Remember that setting up an alert like this will allow Tradingview to fire an alert when a stop or limit order would normally trigger in your backtested strategy. It does not mean that a stop or limit order will actually be placed by your broker.

tv2bt Users

If any readers are currently using tv2bt, then you need to be aware of one potential stumbling block.

If you are providing OHLCV data to Backtrader using the same webhook/alert message as trading signals, then you will receive partial OHLC data. Backtrader will not know this and assume it is a full bar of data. You will get a partial bar because the alert is fired before the close and therefore you have a mid-bar snapshot of the prices. This could then culminate in impacting any indicators that you might be using in Backtrader.

To avoid this issue, it is recommended that you set up two feeds/alerts. One for OHLCV and one for Signalsin Backtrader with tv2bt.

Find This Post Useful?

If this post saved you time and effort, please consider support the site! There are many ways to support us and some won’t even cost you a penny.