Indicator mechanics

Financial Trading in R

Ilya Kipnis

Professional Quantitative Analyst and R programmer

Five steps to calling indicators

  1. Write the add.indicator() function

  2. Supply the strategy name (ex. strategy.st)

  3. Name the function for calculating the indicator (ex. “SMA”)

  4. Supply the inputs for the function as a list

  5. Provide a label to your indicator (ex. “SMA200”)

Financial Trading in R

Using add.indicator()

# 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"))         
Financial Trading in R

Another way to think about indicators

  • 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

Let's practice!

Financial Trading in R

Preparing Video For Download...