CompoundValue

CompoundValue ( int length, IDataHolder visible data, IDataHolder historical data);

Default values:

length: 1

Description

Calculates a compound value according to following rule: if a bar number is greater than length then the visible data value is returned, otherwise the historical data value is returned. This function is used to initialize studies with recursion.

Input parameters

Parameter Default value Description
length 1 Defines length with which the bar number is compared.
visible data - Defines data to be returned if bar number exceeds the specified length.
historical data - Defines data to be returned if bar number is less than or equal to the specified length.

Example

declare lower;
def x = CompoundValue(2, x[1] + x[2], 1);
plot FibonacciNumbers = x;

The example calculates the Fibonacci sequence. Starting from the third bar each following number is calculated as the sum of the previous two numbers while the numbers for the first two bars are equal to one. As a result you will get a plot containing values 1, 1, 2, 3, 5, etc.