View source: R/genericStrategy.R
| addDistributionConstraint.Strategy | R Documentation |
Add constraints to distributions
## S3 method for class 'Strategy' addDistributionConstraint(this, ...)
this |
Strategy |
... |
unnamed expressions under distributions labels |
## Not run:
addIndicators(this, vars = c('spread', 'bb'), expr = {
spread <- data$close[range, ] %*% cbind(c(0.5, -0.5))
bb <- BBands(spread, n = n , sd = nsd)
}, args = list(n = 30, nsd = 1))
addDistribution(this,
component.type = 'indicator',
component.label = 'bb',
sd = seq(0.5,3,0.05),
label = 'bb.sd'
)
addRule(this, name = 'bb_up_dn',
expr = (Lag(spread, 1) > Lag(bb[, 'up'],1)) &
(spread < bb[, 'up']) &
(spread > bb[, 'mavg']) ,
type = 'enter',
args = list(n = 0.005),
block = 'short',
position_const = c(-1, 1))
addDistribution(this,
component.type = 'rule',
component.label = 'bb_up_dn',
n = seq(0.005,0.03,0.002),
label = 'my_distr'
)
addDistributionConstraint(this,
bb.sd > my_distr * 100
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.