addRule: Add rule to strategy

View source: R/genericStrategy.R

addRuleR Documentation

Add rule to strategy

Description

Add rule to strategy

Usage

addRule(
  this,
  expr,
  name,
  lookback,
  args,
  type,
  block,
  pathwise,
  position,
  position_const,
  price,
  on_success,
  reopen
)

## S3 method for class 'Strategy'
addRule(
  this,
  expr = TRUE,
  name,
  lookback = 0,
  args = list(),
  type = "enter",
  block,
  pathwise = FALSE,
  position = NULL,
  position_const = NULL,
  price = NULL,
  on_success = NULL,
  reopen = FALSE
)

Arguments

this

Strategy

expr

expression

name

character, name of signal

lookback

numeric / expression, how many periods is needed for calculation signal

args

list, parameters for a signal

type

character, 'exit' or 'enter'

block

character, it is needed for combining bunch of rules in one namespace. For example rule with type exit will be triggered only if it has the same block variable as entry rule.

pathwise

logical, whether expr will be calculated on each iteration or not. In other words if pathwise is FALSE then expr will be calculated once with indicators, it should return logical vector, then in each iteration element of this vector will be used, if pathwise is TRUE then expr will be calculated at each iteration, it should return logical scalar.

position

numeric vector, what position for each instrument should be at each iteration when model in position

position_const

numeric vector, what position for each instrument should be at entry to position

price

numeric vector, what prices should be used for change position

reopen

logical, whether rule can be reopened on the same bar


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