How does LLVBars work?

I am having trouble understanding the way LLVBars work. Here I am posting a screenshot of exploration I tried.

image

As per my understanding, LLVBars(L, 5) will find the number of bars since lowest low value was reached. So it should work like BarsSince. But as we can see in the highlighted yellow part, it goes from 1-4 but instead of continuing further to 5, its value stays 4 for some more bars and then resets again from 1. We have also the value of BarsSince for comparison.

From docs:

LLVBars:
Calculates the number of periods that have passed since the ARRAY reached its periods period trough.

I think this has something to do with the difference between "trough" and "lowest-low".
Can someone help me in understanding why this happens so?

It can't be 5 because counting starts from 0 (zero) and there are FIVE bars if you count 0, 1, 2, 3, 4 (that's five bars, not four) and you specifically requested to get LLV from 5 last bars.

Bar LLVBars
1 0 - that's the lowest low
2 1 - that's first after LL
3 2 - that's second after LL
4 3 - that's third after LL
5 4 - that is fourth after LL

You are making mistake using L == LLV( L, 5 ) - this only checks if current bar is equal to LLV but that works for current bar only. When you move to next bar, suddenly PREVIOUS bar, the one that wasn't lowest low, could become lowest low for last 5 bars because the "oldest" that is excluded now was the lowest. So LLVBars is obviously NOT the same as BarsSince( L == LLV( L, 5 ) );

This is exactly what happens here:

image

7 Likes

Thanks a lot for explaining it. Its clear to me now.

Great detail information, it helps me a lot.