PINE LIBRARY
ConcatenatedAlerts

Hi all!
This library is useful if you want to concatenate every tick alert for sending on bar close. The 'alert()' function, provided by Tradingview, with the 'freq' parameter set to 'alert.freq_once_per_bar_close' only fires when the realtime bar closes. So if something has happened intrabar, the alert wont be sent.
This library concatenates all alert messages during the bar and sends them on bar close with a header saying how many messages it contains.
It's useful in many cases, but here are a few examples:
When you want alerts for a zone having a breakout (with a candle close) and another one being entered, like this:

When a candle breaks through 2, or more, lines. Like in this example:

There are of course more useful use cases, but above is 2 examples.
The library uses an own enum saying 'alert.freq_all', 'alert.freq_once_per_bar' and 'alert.freq_once_per_bar_close'. The value of this enumeration represents how often an alert will be sent. 'alert.freq_all' and 'alert.freq_once_per_bar' will behave as the once in the 'alert()' function provided by Tradingview. No concatenatination will take place in this case. However, when 'alert.freq_once_per_bar_close' is set, concatenatination will happen with all alert messages during the bar and sent on bar close. Helper functions can be used for both the string value used by the 'alert()' function by Tradingview and this enum type. Example code is provided in the source code, with the usage of input values for both this string and the enumeration.
Hope this is of help!
Concatenate(a_lert, message)
Concatenates all alert messages (called on every tick) to fire all of them with 'Alert()'.
Parameters:
a_lert (Alert): The 'Alert' object to be used for the alert messages concatination.
message (string): The string message to be added to the bar alert.
Alert(a_lert)
When the 'Alert.Frequency' is set to fire on the current tick, this function will concatenate all messages on the current bar and fire an alert. Concatenation will occur if 'alert.freq_once_per_bar_close' is set on 'a_lert.Frequency' separated by new lines and a header saying how many messages the bar contains.
Parameters:
a_lert (Alert): The 'Alert' object to be used for the alert messages concatination and all its 'Messages' will be alerted.
Create(frequency)
Helper function to create an 'Alert' object.
Parameters:
frequency (series Frequency): The 'Frequency' in the created 'Alert' object.
Returns: The 'Alert' object that can be used for concatination.
CreateFromAlertFreq(alertFreq)
Helper function to convert 'alert.freq_all', 'alert.freq_once_per_bar' or 'lert.freq_once_per_bar_close'.
Parameters:
alertFreq (string): The 'alert.freq_all', 'alert.freq_once_per_bar' or 'lert.freq_once_per_bar_close' to convert to 'Frequency' enum.
Returns: The 'Alert' object that can be used for concatination.
Alert
Holds all the values for the 'Alert' to be used.
Fields:
Messages (array<string>): Holds the alert messages within the current bar that will be sent according to 'Frequency'.
Frequency (series Frequency): The frequency for the final alert. One of 'alert.freq_all', 'alert.freq_once_per_bar' or 'alert.freq_once_per_bar_close'. If 'alert.freq_all' is set the alert messages will be fired on each tick and no concatination will occure. The same when 'alert.freq_once_per_bar' is set, but the alert will only fire once per bar. If 'alert.freq_once_per_bar_close' is set concatenation will occure before sending an alert (with all concatenated messages) on bar close.
SkipAddition (series bool): Will skip addition of messages. Used internally if 'Frequency' is 'alert.freq_once_per_bar'.
This library is useful if you want to concatenate every tick alert for sending on bar close. The 'alert()' function, provided by Tradingview, with the 'freq' parameter set to 'alert.freq_once_per_bar_close' only fires when the realtime bar closes. So if something has happened intrabar, the alert wont be sent.
This library concatenates all alert messages during the bar and sends them on bar close with a header saying how many messages it contains.
It's useful in many cases, but here are a few examples:
When you want alerts for a zone having a breakout (with a candle close) and another one being entered, like this:
When a candle breaks through 2, or more, lines. Like in this example:
There are of course more useful use cases, but above is 2 examples.
The library uses an own enum saying 'alert.freq_all', 'alert.freq_once_per_bar' and 'alert.freq_once_per_bar_close'. The value of this enumeration represents how often an alert will be sent. 'alert.freq_all' and 'alert.freq_once_per_bar' will behave as the once in the 'alert()' function provided by Tradingview. No concatenatination will take place in this case. However, when 'alert.freq_once_per_bar_close' is set, concatenatination will happen with all alert messages during the bar and sent on bar close. Helper functions can be used for both the string value used by the 'alert()' function by Tradingview and this enum type. Example code is provided in the source code, with the usage of input values for both this string and the enumeration.
Hope this is of help!
Concatenate(a_lert, message)
Concatenates all alert messages (called on every tick) to fire all of them with 'Alert()'.
Parameters:
a_lert (Alert): The 'Alert' object to be used for the alert messages concatination.
message (string): The string message to be added to the bar alert.
Alert(a_lert)
When the 'Alert.Frequency' is set to fire on the current tick, this function will concatenate all messages on the current bar and fire an alert. Concatenation will occur if 'alert.freq_once_per_bar_close' is set on 'a_lert.Frequency' separated by new lines and a header saying how many messages the bar contains.
Parameters:
a_lert (Alert): The 'Alert' object to be used for the alert messages concatination and all its 'Messages' will be alerted.
Create(frequency)
Helper function to create an 'Alert' object.
Parameters:
frequency (series Frequency): The 'Frequency' in the created 'Alert' object.
Returns: The 'Alert' object that can be used for concatination.
CreateFromAlertFreq(alertFreq)
Helper function to convert 'alert.freq_all', 'alert.freq_once_per_bar' or 'lert.freq_once_per_bar_close'.
Parameters:
alertFreq (string): The 'alert.freq_all', 'alert.freq_once_per_bar' or 'lert.freq_once_per_bar_close' to convert to 'Frequency' enum.
Returns: The 'Alert' object that can be used for concatination.
Alert
Holds all the values for the 'Alert' to be used.
Fields:
Messages (array<string>): Holds the alert messages within the current bar that will be sent according to 'Frequency'.
Frequency (series Frequency): The frequency for the final alert. One of 'alert.freq_all', 'alert.freq_once_per_bar' or 'alert.freq_once_per_bar_close'. If 'alert.freq_all' is set the alert messages will be fired on each tick and no concatination will occure. The same when 'alert.freq_once_per_bar' is set, but the alert will only fire once per bar. If 'alert.freq_once_per_bar_close' is set concatenation will occure before sending an alert (with all concatenated messages) on bar close.
SkipAddition (series bool): Will skip addition of messages. Used internally if 'Frequency' is 'alert.freq_once_per_bar'.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.