I would like to determine at what time and price the indicator triggers in a real-time candle. the script runs with the following header:
//@version=5
strategy("Test", process_orders_on_close=true, calc_on_every_tick=true, max_bars_back = 4000, overlay=true, max_lines_count=500, max_labels_count=500)
I tried to query the price using close, but I only ever see the close price of the candle. This is of course the price that is overwritten until the last tick of the candle. However, even if the candle has expired, I want to determine the price and time that arose when the indicator condition was triggered, not the price and time when the candle was closed. Is it possible to store the price and time in a var and display it in the chart?
Store the price and time in a variable that you have defined with
varlikevar triggertimeif you want their value retained between bars (as normally all other variables are reset and recalculated on each bar).Or if you want to retain this value on the last - currently calculated - bar, you will need to use
varipwhich is the same as thevarabove, just for intrabar purposes (ip ->intrabar persist).