The Price levels lines/label generated by indicator are based on the symbols daily ATR in effect at the moment the levels are generated. However often times the levels sent in the Tradingview Alert when it is triggered will not match the levels calculated and drawn on the chart and often times those lines/levels drawn change in subsequent bars during same session
What is supposed to happen is the price levels sent in the Tradingview Alert when it is triggered are supposed to exactly match the price levels drawn on the chartand they are supposed to remain the same (despite the fact the daily ATR may fluctuate in subsequesnt bars afterwards until the next alert the following trading day when the next session occurs and the Levels are calculated again with the new Daily ATR in effect at the time the levels are initially calculated and alert triggered
Response from Tradingview support regarding repainting issue for line/label plots that use Daily ATR in effect at time of indicator calculating plots
The script example you have provided is using the future leaked data with the http://request.security function call, during the real-time calculations in returns the current data from the higher timeframe, however once recalculated on historical candles it will repaint the results and return the data that was committed at the end of the day and change all calculations based on the return value accordingly. To avoid repainting, you can use the "lookahead = barmerge.lookahead_on" parameter to fetch the current bars with the most recent data of the higher timeframe and offset it with the historical reference operator to link to the closed (confirmed) bar to avoid repainting. We also have prepared an article explaining the http://request.security() function, its parameters and how to avoid repainting while using it that you may find useful: https://www.tradingview.com/script/00jFIl5w-security-revisited-PineCoders/
So withthat reply from TV support - This is what I did.
//atrValue = request.security(ticker, "D", customATR(ta.tr(true), atrPeriod, atrRefBar) , lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_off)
atrValue = f_security(syminfo.tickerid, "D", customATR(ta.tr(true), atrPeriod, atrRefBar), false)
The line that begins with // is now inactive and represents the old way of calculating atrValue. The new line is below and uses a custom function that they recommend called f_security. According to TV support, f_security avoids the repainting issue.
However after implementing this change with f_security the repainting issue still remains. Often times the levels sent in the Tradingview Alert when it is triggered will not match the levels calculated and drawn on the chart and often times those lines/levels drawn change in subsequent bars during same session