Pine Script: Loop Through Input Price levels & set Alerts for Each Price

23 Views Asked by At

Hi I've found a Pine Script V5 indicator that loops through a list of csv price levels input by the user & plots horizontal lines. Is it poss to set an alert at the point of plotting each level in the loop to alert me when price crosses each level? TIA

Pine Script V5 - In my loop of setting a horizontal line, tried various syntax options (see below) but not sure the logic is right as i want an alert to sit at each price level. z_lvl1 is the price I want the alert at. Each loop draws a line at that itteration's Price & I just want an alert to set on the line so it triggers when Price reaches it...

                is_crossed = ta.cross(close, z_lvl1) //str.format("{0,number,####.#####}",str.tonumber(lvl)))

                 Trigger an alert when the condition is met
                alertcondition(is_crossed, "Price crossed ") 
                alertcondition(ta.cross(close, z_lvl1), title="Price crossed", message="Price crossed")
                alertcondition(condition=priceAlert, message="Price Crossed")
                alert(ta.cross(close, z_lvl1), title="Buy Alert", alert_type="Price", frequency="once_per_bar")
                alert(close = z_lvl1, title="Price Alert", alert_type="Price", frequency="once_per_bar")
0

There are 0 best solutions below