Aan de slagGa gratis aan de slag

Using sigFormula()

The last signal function is a bit more open-ended. The sigFormula() function uses string evaluation to offer immense flexibility in combining various indicators and signals you already added to your strategy in order to create composite signals. While such catch-all functionality may seem complicated at first, with proper signal implementation and labeling, a sigFormula signal turns out to be the simplest of logical programming statements encapsulated in some quantstrat syntactical structuring.

In this exercise, you will get a taste of what the sigFormula function can do by stepping through the logic manually. You will need to use the applyIndicators() and applySignals() functions.

Deze oefening maakt deel uit van de cursus

Financial Trading in R

Cursus bekijken

Oefeninstructies

  • Use applyIndicators() with the open, high, low, and close of SPY to generate a dataset object called test_init.
  • Use applySignals() with test_init to apply the signals you wrote in this chapter. Save this new dataset object as test.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create your dataset: test
test_init <- applyIndicators(strategy.st, mktdata = OHLC(___))
test <- applySignals(strategy = strategy.st, mktdata = ___)
Code bewerken en uitvoeren