The code below includes user inputs so that you can change all aspects of the moving averages. So this can be applied to virtually all variations users may want to deploy.
The trick is to use the exact opposite of the condition you want. The scan statements in the code below check if the opposite condition has been false for all of the previous x bars. These use a default value of 100 bars. Adjust that value to whatever length you require.
input maLengthOne = 13;
input maTypeOne = AverageType.EXPONENTIAL;
input maPriceOne = close;
input maLengthTwo = 34;
input maTypeTwo = AverageType.EXPONENTIAL;
input maPriceTwo = close;
def maOne = MovingAverage(maTypeOne, maPriceOne, maLengthOne);
def maTwo = MovingAverage(maTypeTwo, maPriceTwo, maLengthTwo);
def stackedAbove = maOne > maTwo;
def stackedBelow = maOne < maTwo;
# use this to scan for maOne above maTwo for previous x bars
plot scan = Highest(stackedBelow, 100) == 0;
# use this to scan for maOne below maTwo for previous x bars
#plot scan = Highest(stackedAbove, 100) == 0;