When I compare the 2 methods, SMA()
needs close price as first parameter in xts format and DonchianChannel()
needs HL in xts format. However the usage is Cl(mktdata)
for SMA vs HLC(mktdata)[, 1:2]
for DonchianChannel()
.
Why is this so? why cannot i just use HLC(mktdata)
?
add.indicator(strategy = strategy.st,
name = "SMA",
arguments = list(x = quote(Cl(mktdata)),
n = 30),
label = "nSlow")
add.indicator(strategy = strategy.st,
# correct name of function:
name = "DonchianChannel",
arguments = list(HL = quote(HLC(mktdata)[, 1:2]),
n = 20),
label = "DCH"
)