I'm having a nightmare with data in TradingView when using security and alert!
I'm using security to pull the data of 40 different symbols from the BYBIT exchange.
symbol1_close = request.security(symbol1, timeframe.period, close)I'm using label.new to show the coin name and its closing price on each candle using 1 min timeframe
I'm using
alert(data, alert.freq_once_per_bar_close)to send the same data on bar close. I send the data of close and close[1]
When looking at the data I see that close from the chart is different to the data sent in the alert for many coins. Some are still the same, but due to these differences the script that runs with the alerts takes different decisions than the one in the chart.
Is there a way to get alerts and chart data to access the same data to minimise or fully prevent this issue?
Initially I thought this is caused by the typical repainting which would be expected if security was using a higher or lower timeframe, or using some TA functions that do repaint. But in this case is only close and in the same TF as the chart.
I have the following hypothesis: H1) TV data used for alerts has access to different data than local charts (one is delayed?) H2) Bybit updates data post bar close. Maybe some pieces of data are arriving to TV slightly late but before the alert is processed giving the alert more precise and up-to-date data than the chart that ends up plotting and settling right on time. Once I refresh the chart I swear I have seen some historic closing prices in the labels slightly changing.