break out signal indicator help pls

 

hello
i have a indicator which check break out price line.
here we can see Red line is sell line and Blue is buy line.
when price break Red sell line i want to get alert vice versa Blue buy line.
but i want to wait upto 2 bars until Red or Blue signal bar break out signal bar.
for instance, below picture yellow number 1 is valid signal because it break Red line in 2 bars so want to get alert.
also yellow number 2 is valid because it also break down red line but number 3 is not valid because it not break in 2 bars.
number 4 Blue also invalid because it didn't break and also number 5 is invalid.
pls help me! thanks much


Files:
smtest.mq4  7 kb