I will assume that the script should search for lower lows and higher highs. Allow me to know if this is wrong.
For verifying my results, I marked the chart with arrows. I will depart this logic intact from the script. If you would like to turn it off, change this line from true to false and recompile. I think you will want to maintain the arrows annotating once you see how successful they are.
Extern bool showArrows = true;
If you've any other programming requests related to this, let me know. You are able to use this forum or PM me.