Price if condition is met

49 Views Asked by At

I try to give out the real price when a condition is met. I tried using ta.valuewhen for this. Since I have to provide a source in the code, the price is always displayed after the source. So if I specify close as the source, the price is also displayed that way. Same with open. How can I display the price that is determined directly when the condition is met? It is important that the script works in real-time mode and that I want to determine the price when the candle is set up and the conditions are met

This is what I tried:

 preis_short := ta.valuewhen(show_short == true, open, 0)
1

There are 1 best solutions below

1
vitruvius On

You won't have the intrabar price actions on the historical bars. So, you won't be able to determine what the price was when something happened.

In real-time bars, close refers to the last (current) price. So, you can save/use that information.