Reputation: 37
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?
Upvotes: 0
Views: 46
Reputation: 2618
Store the price and time in a variable that you have defined with var
like var triggertime
if 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 varip
which is the same as the var
above, just for intrabar purposes (ip -> intrabar persist
).
Upvotes: 0