Consecutive Alerts from Custom TradingView Screener

Consecutive Alerts from Custom TradingView Screener

Screeners are crucial tools for traders, providing a way to filter stocks and other financial instruments based on specific criteria. This allows traders to efficiently identify potential investment opportunities that align with their trading strategies. By leveraging screeners, traders can save time, focus on high-potential prospects, and make informed decisions based on data-driven analysis, enhancing their overall trading performance.

TradingView, while popular among traders for its comprehensive charting tools, lacks robust options for custom screeners, limiting users’ ability to tailor screens precisely to their needs. To address this gap, I’ve developed a unique hack that allows users to create a screener that displays up to 40 instruments on TradingView’s interface as an indicator. Recently, I’ve also added alert functionality to this screener. I am now exploring various methods to send alerts from the screener, aiming to enhance its utility and responsiveness for active trading scenarios.

In this article, I will demonstrate how you can configure TradingView’s custom screener to send consecutive alerts. Specifically, this means that if multiple instruments trigger an alert at the end of a bar, TradingView will send individual alerts for each instrument rather than a single alert for all of them. This feature ensures that you receive separate notifications for each trading signal, enhancing your ability to respond promptly and accurately to market movements.

This capability can be extremely beneficial if you want to simultaneously automate a strategy across multiple instruments. With this approach, you could issue entry and exit orders for up to 40 different instruments from a single screener, streamlining your trading process and enhancing efficiency.

This article will utilize my Multiple Indicator Screener, which I have made available as an open source on TradingView. This screener already includes alert functionality. We will modify it appropriately to enable it to send alerts consecutively.

First, we must define a new area to store the alert messages we want to send. In this example, we’ll send only the symbol name, but you can also try to send orders, like “SELL BTCUSDT,” “BUY BTCUSDT,” etc., depending on the conditions of your screener conditions:

alert_arr = array.new_string(0)

Next in a loop, if our filtering condition is true we’ll push a new element to the defined array:

 if is_filt
     alert_arr.push(id_symbol(matrix.get(screenerMtx, i, 0)))

And lastly, now we need to send all the alerts separately:

varip last_alert_bar_sent = 0

if barstate.isconfirmed    
    if array.size(alert_arr) > 0 and time_close > last_alert_bar_sent
        last_alert_bar_sent := time_close
        for i = 0 to array.size(alert_arr) - 1  
            alert(array.pop(alert_arr), freq = alert.freq_all)

Here, we check that “barstate.isconfirmed” to pick values for the bar close, and we send them as alert() with the freq_all parameter. This will send alerts immediately, one after another. You need to be aware of TradingView’s limitation on the number of alerts. You can’t get more than 15 alerts in 3 minutes, or your alerts will be stopped out. Also, there was a bug with the Barstate.isconfirmed launched the code twice. I overcome this with the introduction of the last_alert_bar_sent variable.

So that’s it. After that, your screener will send you consecutive alerts. So here is the filtered screener with five instruments that I want to receive alerts for at the end of the bar:

The code I created will send separate alerts for all these symbols separately:

This is a pretty simple hack, but it can be quite powerful. You theoretically can automate dozens of instruments simultaneously with orders from 1 screener. But this method is still experimental, so please spend some time testing it before applying it to real accounts.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Pine Script Programming Courses
Pine Script Programming Courses
Learn to build your own TradingView Indicators and Strategies
Sidebar Signup Form
If you want to be the first in this business, subscribe to the latest news