LLV & HHV - finding low and high for a number of days

I am trying to construct a strategy that finds stocks that have hit a 7-day low, but when I test, it finds no stocks over several years, so I must not be coding the idea correctly. Here are the lines as I have written them:

Buy =			
		Close < LLV(Close, 6);	//close is at 7-day low					
Sell =
		Close > HHV(Close, 6);	//close is at 7-day high

I can't see what is wrong with these. Thanks.

@JohnHoward I think you need to review this post,

For example, run an exploration and see what your code is generating compared to what you are actually attempting to achieve.

May I suggest that you review the proper use of the functions,


Calculates the lowest value in the ARRAY over the preceding periods ( periods includes the current day)

Try something like this (I'm on my phone so can't properly check if this works),

SevenBarLow = Close < Ref( LLV(Close, 6), -1);

another possible variation

Close == LLV(Close, 7)

Function LLV returns the lowest value of the last "period" bars , included the current one. For this reason a condition like:

Close < LLV(Close, 6);

return always false, because a number can not be strictly lower than it self.


2DD, Thank you. I see the error.

Thank you, that's what I was not seeing.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.