VARIABLESETBACK

Top  Previous  Next

Keyword Description

Programatically specify a variable look back period

Class

Directive

Where Legal

Resources

Entry Logic

Exit Logic

Initial Size

Resize

(Pre-Category)

Resize

(Category-Level)

l

l

l

 

 

 

Syntax

VARIABLESETBACK

 

Example

Sample code

COL1 = ATR[75]

COL2 = 100 / COL1[1]

X = COL2

VARIABLESETBACK = X

COL3 = SMA[CLOSE,X] ' no trades before day X

 

ThumbTack white

SETBACK is used to increase the number of days that Mechanica allows for math routines to get "up to speed" before making its first trade, but VARIABLESETBACK should be used when the number of days in an indicator calculation changes over time.

(Mechanica automatically calculates the number of days your math routines need to become meaningful and will not execute a trade before then. In the case of exponential moving averages, Mechanica allows 15 days for startup time. SETBACK and VARIABLESETBACK allow you to increase this value.)

The example above shows a volatility adjusted moving average. It uses a variable look back which is assigned to the variable X (which always returns an integer), and used in the calculation of the simple moving average in column 3:

See also:

SETBACK