Situation:
I’m making an alert that will ring my computer if the 20 moving average crossover 50 moving average
the first 19 row for 20 moving average is NaN and the first 49 rows of 50 moving average is also NaN
What I want to do:
for the current and latest row (current fresh close data) I want to know how to calculate the crossover if it’s NaN?
Should I calculate it like..
for x in range(len(data)):
current_short_ma = data.iloc[x+20]["short_ma"]
current_long_ma = data.iloc[x+50]["long_ma"]
or should I just get the first NaN value of the longest period indicator?
I was expecting to be alerted as as soon as I get the latest closed value
2