Skip to content
Prev 12695 / 15274 Next

questions about order price and timestamp in quantstrat

RSI 50 and RSI 70 will do exactly what you want on one caveat--that if
the indicator waggles around 50 before reaching 70, you'll sell twice
at the 50 cross. Or you can use a chain type of order (see R/Finance
2013 quantstrat presentation), with a separate signal generating
column, using the 50 sell rule as a parent.

Regarding "rule execution on signal bar", there's an argument in
ruleOrderProc called allowMagicalThinking. However, that's not
recommended. If you wish to delay the SMA computations and add lag,
just write a custom indicator function.

lagSMA <- function(x, n=200, k=2) {
 sma <- SMA(x, n=n)
 out <- lag.xts(sma, k=k)
 colnames(out) <- "lagSMA"
 return(out)
}

Regarding pyramiding, what I'd suggest you look at is chain rules, and
as above, use your initial buy rule as a parent, but use a separate
signal column, so when you hit your RSI10, you'll also check the
profitability of your position from the RSI30, and if both conditions
hold, you should get an order. I don't use pyramiding code myself (and
this also seems like a contradictory rule--an RSI going from 30 to 10
probably means the price has gone down, not up).

Hope this helps.

-Ilya
On Wed, Sep 3, 2014 at 3:21 AM, domodo <1111938 at qq.com> wrote: