Skip to content

Instantly share code, notes, and snippets.

@josephdunn
Created March 2, 2012 00:52
Show Gist options
  • Save josephdunn/1954384 to your computer and use it in GitHub Desktop.
Save josephdunn/1954384 to your computer and use it in GitHub Desktop.
RocSys = function(x, nEMA, nROC, nTREND)
{
rocema = ROC(EMA(x, nEMA), nROC)
trend = EMA(x, nTREND)
signal =
ifelse(rocema>0 & lag(rocema)<=0, ifelse(x>trend, 1, 0),
ifelse(rocema<0 & lag(rocema)>=0, ifelse(x<trend, -1, 0),
NA)
)
signal <- na.locf(signal)
return(signal)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment