Parameters and Constants

You can include user defined variables in PCF functions that are declared as either a constant or a parameter. Parameters can be re-defined when calling a function into a new formula, constants can not. Both need to be declared at the top of the function.

Both Parameters and Constants work as text replacements within a formula. They can make formulas easier to read, increase the ease with which values can be changed and, allow you to pass through values from higher functions. They do not allow you to do math that you could not do in a long form formula.


Parameters are declared using the "param" prefix,  their names must begin with # and must be followed with an equals sign and a default value, parameter values can be passed down from higher level functions


Constants are declared using the "const" prefix,  their names must begin with # and must be followed with an equals sign and a default value

Example using both parameters and constants

In this example we will create a simple formula for percent change using both variable types. If you need a refresher on % change please see this article. First we will click on the hamburger button and select add new function, for more on this menu please see this article

We will then create our Percent change formula. You can see there are 4 variables, 2 parameters (#BarValue, #Span) and 2 constants (#Combine, #Math) we have used comments to define the function and parameters, for more on this please see this article.

Once we have completed the function click on OK, the function has now been called into our main formula window, you can see that the 2 user defined parameters (#BarValue, #Span) are available as well as the offset parameter which is automatically given to all functions. The 2 constant values can not be changed from this window.

Lets call in the function by typing # and selecting the function from the dropdown menu, you can see the function description as well as the parameter default values.

Lets set the function value greater than 2 (greater than a 2% move) and we can click on the show formula button to see if we are getting the expected results, as you can see it is passing through our default parameter values and the constants are combining the parameters correctly.

Lets test this further by changing the #BarValue and #Span values, to do so place the new variable values in parentheses after the function as shown in the function window, lets change #BarValue to H and #Span to 20, we will then click the show formula button again to show the new values have been passed through

Lets show this one more time but we will now include an offset value as well, we will give it a value of 1, clicking the show formula button confirms that we are calculating the 20 bar % change of High as of 1 bar ago.