Sorry but the code you provided had some serious flaws that could not be corrected without radically overhauling the entire thing. So I generated my own solution from scratch. And it actually took me less time to build from scratch than trying to fix the code you provided.
If you are interested in learning I will point out one flaw that was preventing your code from working:
plot UpSignal = price crosses above DailySMA;
plot DownSignal = price crosses below DailySMA;
Those two lines should be as follows:
plot UpSignal = Fundamental(price, period = aggregationPeriod) crosses above DailySMA;
plot DownSignal = Fundamental(price, period = aggregationPeriod) crosses below DailySMA;
But that only works if you set the chart to a daily time frame. When you set it to an intraday time frame it creates even more problems than your original solution. The only way to do this properly, so that it works on intraday time frames as well as daily time frame, is to use recursive variables.
Here is the solution that works as you intended. However it is missing a few features. Such as it does not have an input to change the price type and it does not include any way to displace the moving average or force it to only display on the last period.
input maLengthOne = 20;
input maTypeOne = AverageType.SIMPLE;
input timeFrameOne = AggregationPeriod.DAY;
plot maOne = MovingAverage(maTypeOne, close(period = timeFrameOne), maLengthOne);
rec trackUpSignal = if close[1] < maOne[1] and close > maOne then 1 else 0;
rec trackDownSignal = if close[1] > maOne[1] and close < maOne then 1 else 0;
plot upSignal = trackUpSignal and !trackUpSignal[1];
upSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upSignal.SetDefaultColor(Color.CYAN);
upSignal.SetLineWeight(3);
plot downSignal = trackDownSignal and !trackDownSignal[1];
downSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
downSignal.SetDefaultColor(Color.MAGENTA);
downSignal.SetLineWeight(3);
Alert(upSignal, "Price crossing above", Alert.BAR, Sound.RING);
Alert(downSignal, "Price crossing below", Alert.BAR, Sound.RING);