Financial Trading in R
Ilya Kipnis
Professional Quantitative Analyst and R programmer
Write the add.indicator()
function
Supply the strategy name (ex. strategy.st)
Name the function for calculating the indicator (ex. “SMA”)
Supply the inputs for the function as a list
Provide a label to your indicator (ex. “SMA200”)
# Call add.indicator() with strategy, name, arguments, and label
add.indicator(strategy = strategy.st, name = "SMA",
arguments = list(x = quote(Cl(mktdata)),
n = 200), label = "SMA200"))
Applying an indicator is similar to using the apply()
command in R
You pass in the name of a function along with arguments
The key difference is the addition of a label for your indicators
Financial Trading in R