Pinescript getting price value of lowest stoch value

Viewed 51

I am looking for the lowest stoch value between 2 stoch up crosses. I have found how to do this and this code works nicely. Now what i would like to do, is find the bar_index of this pivotlow so i can find the price candle it's open or close price. How can i achieve this? The code i sed for finding the lowest pivot value is:

stochLow = pivotlow(k, stochCrossUpAt - stochCrossUpAtPrevious, 1)

This gives me the correct lowest value, but now i want to know the lowest price went at this point.

Any ideas?

1 Answers

You can easily do this by using valuewhen()

sBarIndex = valuewhen(stochLow == k, bar_index, 0)
sLow  = valuewhen(stochLow == k, low, 0)
sOpen = valuewhen(stochLow == k, open, 0)
Related