Created
December 11, 2010 20:47
-
-
Save milktrader/737641 to your computer and use it in GitHub Desktop.
white bull algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
white_bull <- function(ticker) { | |
require("quantmod") | |
x <- getSymbols(ticker, auto.assign=FALSE) | |
c <- x[,4] | |
c50 <- SMA(c, n=50) | |
c200 <- SMA(c, n=200) | |
last_c <- tail(c, n=1) | |
last_c50 <- tail(c50, n=1) | |
last_c200 <- tail(c200, n=1) | |
if (last_c > last_c50 && last_c > last_c200 && last_c50 > last_c200) | |
{ print("I am a bull market") } | |
else | |
{ print("I am NOT a bull market") } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment