Code for eliminating same signal within x prior bars

I currently have these 2 codes in a strategy:
BreakoutLength = Param("Length of Breakout",65,50,260,10);				
Rule5 = Close==HHV(C,BreakoutLength);				

I would like to add a filter so that results are eliminated if a new high of 30 bars has already occurred more than 2 times in the prior 6 months(approx 130 daily bars).  In other words, I wouldn't want a result returned if this current new high (Rule5) is the 3rd high or more within the last 130 bars.  From my research on this site, I found a code and modified it to what I think would be correct.  Can someone verify if this code would accomplish that or help me with a better way to do it?  Thanks.
Rule6 =  sum(C==HHV,30), 130) <=2;

-> Rather:

Rule6 = Sum(C==HHV(C,30), 130) > 2;

or with delay

Rule6 = Sum(C==HHV(C,30), 130) > 2;
Rule6 = Ref(Rule6,-1);

Thanks fxshrat! Appreciate your help.

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