Description Usage Arguments Details Value Author(s) Examples
Constructs an indicator (1
for long, -1
for short, 0
otherwise). The
entries and the exits are provided as boolean vectors, separetely for long and short positions.
1 | construct.indicator(long.entries, long.exits, short.entries, short.exits)
|
long.entries |
A boolean vector indicating (TRUE) the long entries |
long.exits |
A boolean vector indicating (TRUE) the long exits |
short.entries |
A boolean vector indicating (TRUE) the short entries |
short.exits |
A boolean vector indicating (TRUE) the short exits |
Designed to maintain a single position only.
Implemented in C++ - fast.
An object of the same class as long.entries
containing a single column. The positions are
encoded as 1
, -1
and 0
for long, short and none, respectively.
Ivan Popivanov
1 2 3 4 5 6 7 8 9 10 11 12 | ## Long entries when RSI2 > 90, long exits when RSI2 < 30
## Short entries when RSI2 < 10, short exits when RSI > 70
require(quantmod)
spy = getSymbols("SPY", auto.assign=FALSE)
rsi = RSI(Cl(spy), n=2)
lentries = !is.na(rsi) & rsi < 10
lexits = !is.na(rsi) & rsi > 70
sentries = !is.na(rsi) & rsi > 90
sexits = !is.na(rsi) & rsi < 30
indicator = construct.indicator(lentries, lexits, sentries, sexits)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.