Hi,What makes you think there is something wrong with your script?
In order to troubleshoot the issues. We need to be able to see what you are seeing. So we need you to provide a screen grab of the wonky results. Make sure to grab the whole chart so we can see the aggregations, what stock, and all your settings so we can try to replicate your results and correct them.
After you post the above information, I am sure someone will be able to point you toward possible solutions and a watchlist.
Unsure of how to upload screenshots to the forum, Here are directions.
I setup the script, however it didn't notify me a bar prior to the ema crossover, it was when the crossover happened. Please see attached screenshot and my script.
input EMAPeriod1 = 13;
input EMAPeriod2 = 48;
input price = close;
def na = double.nan;
plot ema1 = ExpAverage(price, EMAPeriod1);
plot ema2 = ExpAverage(price, EMAPeriod2);
def crossover_1_2 = if ema1 > ema2 AND ema1[1] <= ema2[1] then 1 else 0;
def crossunder_1_2 = if ema1 < ema2 AND ema1[1] >= ema2[1] then 1 else 0;
#Plot arrows
Plot up = if (crossover_1_2) then low – tickSize() else na;
Plot down = if (crossunder_1_2) then high + tickSize() else na; up.SetPaintingStrategy(paintingStrategy.ARROW_UP); down.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);
#Trigger alerts
alert(crossover_1_2[1], “Crossover_1_2”, Alert.Bar, Sound.Ding);
alert(crossunder_1_2[1], “Crossunder_1_2”, Alert.Bar, Sound.Ding);
14151[/ATTACH]']