Navigating the PCF Functions, Parameters, and Constants Menu
This menu is available from anywhere you would edit either a indicator or Condition (boolean) formula. In this example we are using the Indicator (PCF) Formula from the New Menu. This article will walk you through the functionality of each of the menu items and conclude with an example of these items in use. Please refer to the help articles on Constants, Parameters and Functions for more specific details on each of those items.
Click on the hamburger button to open the menu.
This opens a menu which allows you to choose from several items to add to your formula
Click on Add parameter and this dialog box will appear
This dialog allows you to name your parameter, assign it a default value, and add a tagged description of what that parameter does, in this example we will name it "Period" give it a value of "20" and set the description to "Defines number of bars in period"
Select OK to add it to the PCF editor window
This is how a parameter will appear in the editor window
Please note that Parameters must always be entered above the formula, you can also type in the parameter using the above syntax instead of adding it using the menu button.
We will now show how to call the function, parameter and constant in an example formula that describes where the current price "C" is relative to the maximum high and minimum low of the last 20 bars and creates and average of that value. Please note that the purpose of this formula is to show how these items can be utilized and should not be considered a recommended indicator in any way. The formula we will be creating is:
AVG(((MAXH20) - C) / (C - MINL20), 20)
First add the function Avg to the formula followed by two opening parentheses
Note that as you type the code completion gives you a list of available functions and declarations as well as a description of that function. You can use the up and down arrows to move through the list of functions, pressing enter will select the highlighted function.
Next we will call the MaxHigh function
User Functions, Parameters, and Constants all begin with the pound sign "#"
Note the description for this function is what was entered between the <desc> tags previously
Now we will add a minus sign and call our OHLC constant then add a closing parentheses
Note the description of the constant matches what is placed between the <desc> tags to the right of the defined constant
Next we will add a division sign and subtract the 20 period minimum low from our OHLC constant
MINL20 could have been saved as it's own user defined function, it was entered this way to show the use of user defined functions and system functions.
Finally we will call our period parameter to define the period of the average and add the final closing parentheses to complete the formula
Note the description of the parameter matches what is placed between the <desc> tags to the right of the defined parameter