Help with the codes

Hi,Can one help me with codesfor the following
1)CODES FOR COMPARING TWO FRACTAL BELOW;
A)Two downward fractal following each other where the last down fractal breaks the second downward fractal with no other fractal in between

B)Two upward fractal following each other where the last upward fractal breaks the second last upward fractal with no other fractal in between

2)A code that will eliminate fractals that forms on the same bar