Implementing an indicator - II
Great job implementing your first indicator! Now, you'll make your strategy even more robust by adding a 50-day SMA. A fast moving average with a slower moving average is a simple and standard way to predict when prices in an asset are expected to rise in the future. While a single indicator can provide a lot of information, a truly robust trading system requires multiple indicators to operate effectively.
In this exercise, you'll also add this 50-day SMA to strategy.st. The quantstrat and quantmod packages are also loaded for you.
Diese Übung ist Teil des Kurses
Financial Trading in R
Anleitung zur Übung
- Use
add.indicator()on your existing strategystrategy.st. Follow the example code in the previous exercise. - Provide the SMA function as the
nameargument. - Specify the desired arguments of SMA, using the closing price of
mktdataand a lookback periodnof 50 days. Don't forget to use thequotefunction! - Label your new indicator
"SMA50".
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Add a 50-day SMA indicator to strategy.st
add.indicator(strategy = ___,
# Add the SMA function
name = "__",
# Create a lookback period
arguments = list(___),
# Label your indicator SMA50
label = ___)