Find stocks closing above previous high

Hello,

I want to find stocks which are closing above previous close at least 2 times in last 5 trading sessions.

Buy=C>Ref(C,-1); How to frame the logic for " atleast two times in last 5 trading sessions "?//
Filter =Buy;
AddColumn( Close, "Close" );

Thank you

If it is EOD:

Buy=C>Ref(C,-1); 
//"atleast two times in last 5 trading sessions "
Buy = Sum(Buy,5) > 1;
//Buy = Ref(Buy,-1);// delay
Filter = Buy AND Status("lastbarinrange");
AddColumn( Close, "Close" );

4 Likes

Thank you so much. Yes it's EOD

Isn't it > 2 ? for the condition at least two times? just asking out of my ignorance.

@amisur you wrote

That means you want a true condition if the sum is 2,3,4, or 5. If you use > 2 then you will only get a true if the sum is 3,4,5 (all greater than 2). So you can use either

Sum(Buy,5)>=2

or

Sum(Buy,5)>1;

No, it's not!

I do not write things just for sake of posting.
>1 includes two -> 2,3,4,5 are greater 1.
if you write > 2 then it only looks for at least three occurrences.
And why writing >= 2 if you just have to write > 1...

2 Likes

Thank you for the explanation. I misunderstood the expression.

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