env=baseenv() in R

I’ve been playing around with the Life Analytics trading with R tutorial (http://lifeanalytics.blogspot.com/2011/01/forex-trading-with-r-part-1.html) and keep getting stuck on a problem related to building the data model.

So I start with a bunch of functions:

myATR <- function(x) ATR(HLC(atrx))[,'atr']
mySMI <- function(x) SMI(HLC(smix))[,'SMI']
myADX <- function(x) ADX(HLC(x))[,'ADX']
.
.

Then try to build a model passing the data to the functions:

data.model <- specifyModel(myATR(AUDCAD)+mySMI(AUDCAD)...)

And keep getting the following error:

Error in formula.default(object, env = baseenv()) : invalid formula

I’ve read the following post, but do not understand it well enough to implement a solution: formula error inside function

Can anyone explain this in simpler terms? I need some help getting my hook into understanding environments better.

Leave a Comment