Nested functions

Nested functions are functions used within other functions. A simple series mnemonic can be replaced with a second function. For example:

PCH#(JAPYNUS,1M)

This calculates the monthly percentage change in the US Dollar-Japanese Yen exchange rate.

You can replace the exchange rate mnemonic by a function, the moving average of the exchange rate.

PCH#(MAV#(JAPYNUS,1M),1M)

This new function calculates the monthly percentage change in the monthly moving average for the US Dollar-Japanese Yen exchange rate. This generates a much smoother trend line.

You can combine, or nest, up to 50 functions in a single expression. You can place functions anywhere in an expression. For example, to show the deviation of the actual Marks and Spencer share price around the 30 day moving average (by subtracting the moving average from the actual price. positive values indicate a rising average), type:

MKS-MAV#(MKS,30D)

Nested functions are subject to the following rules:

These rules allow to construct highly complex expressions. For example, the expression for historic volatility is:

POW#(12,0.5)*SDN#(LN#(X/LAG#(X,1M)),60M)

In this example, LN# and LAG# are nested within SDN#, where X is a series mnemonic. This expression has two function blocks: POW# defines the first, and SDN# defines the second. See Creating and storing expressions for further information.

Note Nested functions are self-contained functions, complete with mnemonics and date parameters, contained within a second function. They are quite distinct from function codes without parameters used as arguments in other functions - see Using function codes as arguments.