I want to clarify something. You said
So you have 3 signals lets call them according to the color you have on the scope. Yellow, Blue and Violet. Do you want to count the number of violet rising edges from the time between both yellow and blue are HIGH? Maybe you can give an example by drawing the wave in a piece of paper and your expected results.
Also there should be 3 inputs (yellow, blue and violet) but your program only uses 2 inputs (pin2 and pin 3).