addDistribution: Add distribution

View source: R/genericStrategy.R

addDistribution.StrategyR Documentation

Add distribution

Description

Add distribution

Usage

## S3 method for class 'Strategy'
addDistribution(
  this,
  component.type = "params",
  component.label = NULL,
  label,
  variable = list(),
  ...
)

Arguments

this

Strategy

component.type

character, one of rule, indicator, params

component.label

character vector, name of component, argument name is resposible for that. If component.type is params than component.label can be omitted (default value all will be passed) or equal to argument type from setParams function

label

character, name for this distribution. It only needed if constraints will be used. This label will be used there as a name for this distribution.

variable

list, This field should be used if name if one of your params coincide with arguments of this function, if not ... can be used. Each cell must have a name and include array, as list(n = c(1, 2, 4), eps = c(0.01, 0.02)).

...

named array of params, as n = c(1, 2, 4), eps = c(0.01, 0.02)

Examples

## Not run: 
addIndicator(this, name = 'bb', expr = {
   BBands(data$close[range, 1], n = n , sd = nsd)
 }, args = list(n = 30, nsd = 1))
addDistribution(this,
    component.type = 'indicator',
    component.label = 'bb',
    nsd = 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']) &
                  (abs(spread - bb[,'mavg'])  > n) ,
     type = 'enter',
     args = list(n = 0.005),
     block = 'short')
addDistribution(this,
    component.type = 'rule',
    component.label = 'bb_up_dn',
    n = seq(0.005,0.03,0.002),
    label = 'my_distr'
)

## End(Not run)

Vitalic57/stratbuilder3gen documentation built on March 30, 2022, 6:58 a.m.