search for: abovesma

Displaying 1 result from an estimated 1 matches for "abovesma".

Did you mean: aboves
2012 Sep 04
1
Producing a SMA signal when closing price is above the moving average for 3 days
...rice closes above the SMA for 3 days. Thank you, Douglas library(quantmod) getSymbols("GE") # Get Price Data GEsma <- SMA(GE$GE.Close, n=50) # Simple Moving Average of the closing price GEsma[is.na(GEsma)] <- 50 # Make NA's to 50 so ifelse statement works correctly aboveSMA <- ifelse(GE$GE.Close > GEsma, 1, 0) # 1 when price is above 50 day moving average # 0 When below moving average chartSeries(GE) # Shows Price chart addSMA(n=50) # adds 50 day moving average to chart