How to avoid LLV looking beyond the current bar

Dear all,

The following is part of my code for identifying pivot lows. It will, for example, flag a previous bar that is lower than the 10 bars either side of it. The problem is that this code will look beyond "today's" bar which is wrong because as of 'today', the pivot bar conditions were not met. How do I avoid this? Thanks in advance...Tim.

Size=10;
LeftPeriodLow = LLV(L,Size+1); // LLV of x bars to the left (plus current bar)
RightPeriodLow = Ref(LeftPeriodLow,Size); // LLV of x bars to the right
PivotTrue = LeftPeriodLow == Low AND RightPeriodLow == Low; // creates an array of TRUE/FALSE at each pivot location
Pivots = ValueWhen(PivotTrue,Low); //creates an array of Pivot LOWs

Hint: From your previous Thread, there is a technique applied using BarIndex()

@timhopson,

You need to use the 'Code' button when inserting your code. See How to use this site.

Size=10;
LeftPeriodLow = LLV(L,Size+1); // LLV of x bars to the left (plus current bar)
RightPeriodLow = Ref(LeftPeriodLow,Size); // LLV of x bars to the right
PivotTrue = LeftPeriodLow == Low AND RightPeriodLow == Low; // creates an array of TRUE/FALSE at each pivot location
Pivots = ValueWhen(PivotTrue,Low); //creates an array of Pivot LOWs

Hi Travick, Agh! Of course, I see now. I should have spotted that one. Thanks. For the benefit of anyone with a similar question, the amended code is below...

LeftPeriodLow = LLV(L,Size+1); // LLv of x bars to the left (plus current bar) RightPeriodLow = Ref(LeftPeriodLow,Size); // LLv of x bars to the right BI=BarIndex(); PivotTrue = LeftPeriodLow == Low AND RightPeriodLow == Low AND bi+1<(BarCount-Size);

2 Likes