The code needs to reset at the opening bar of each trading session. I see your chart did not included extended hours data so my solution also requires that extended hour data NOT be included. Otherwise the results will not work. I also need to mention this will only work for intraday time frames.
The missing piece for you was the use of a recursive variable. I have created a new variable named "newDay" that is used to reset the signal for each new trading session. For each bar after the opening bar the code checks if the crossover has occurred. When any crossover occurs the value for "hasCrossedToday" is set to 1 and held for the reminder of the trading session.
Oh and I have included two signals with this scan. The one you requested as well as one that will be triggered on the exact same bar the first crossover of the day occurred.
I have not tested this, but based on my experience it should work:
input numberOfCrosses = 1;
input maLengthOne = 9;
input maTypeOne = AverageType.EXPONENTIAL;
input maPriceOne = close;
def maOne = MovingAverage(maTypeOne, maPriceOne, maLengthOne);
def closeXBelowEMA = close[1] > maOne[1] and close < maOne;
def newDay = GetDay() <> GetDay()[1];
rec hasCrossedToday = if newDay then 0 else if closeXBelowEMA then 1 else hasCrossedToday[1];
# use this to find stocks that have crossed at least once during today
plot scan = hasCrossedToday > numberOfCrosses;
# use this to find stocks that have just crossed for the first time today
#plot scan = hasCrossedToday and !hasCrossedToday[1];