How to find close price at occurrence of largest down close between 3 and 20 bars back

I am trying to find the closing price of the bar that had the largest down close between 3 and 20 bars back. I have found the largest down close amount in the span like this:

``````LargestDownCloseSetup = llv( Close-Ref(Close,-1), 17);
LargestDownCloseAmount = Ref(LargestDownCloseSetup, -3);
//LargestDownClosePrice = ???????
``````

But now how do I acquire the closing price of the bar that this largest down close actually happened on?

Take a look at the `ValueWhen()` function.

``````BarsLargestDownCloseSetup = LLVBars( Close-Ref(Close,-1), 17);
LargestDownClosePrice = Ref(Close, -BarsLargestDownCloseSetup);
``````

@awilson @vjsworld I am under the impression he wants to look between 3 bars ago and 20 bars ago. So might need one more calculation added to @awilson 's code, maybe

``````BarsLargestDownCloseSetup = LLVBars( Close-Ref(Close,-1), 17);
LargestDownClosePrice = Ref(Close, -BarsLargestDownCloseSetup);
BetweenDay3And20 = Ref(LargestDownClosePrice, -3);

``````

perfect! Thanks portfoliobuilder and awilson