Introduction To Functions

Personal Criteria Formulas (PCF's) now support the use of user created functions. Functions are no more than a re-usable formula that can have user defined variables. When saved, any PCF can be re-used as a function within another PCF.

For this example we will start by clicking the new button and selecting Condition (PCF) Formula

While we begin this example using the New button there are multiple ways to access the PCF editor in TC2000, anywhere you access the editor you will have this functionality

To access functions click on the hamburger button in the PCF editor

For more information on the items in this menu please see this article

You can then choose to create a new function or add a function from the library (any saved PCF condition or indicator is available in the library). For this example we will elect to add a new function.

This will open a second editor window for your function. The window will pre-load with description and tag  comments

For more on comments please see this article

The first function will be a simple formula for positive net change, C>C1, the current price is greater than the previous bars close. We will put that in description and we will name this function Bullish

Function names can only contain alphabetical characters

We will then click OK to bring it into the original PCF editor window

We now see this function available with an optional offset parameter, by default all functions load with this parameter available

For more on parameters please see this article

We will now call the function in our Formula, type the # symbol and code completion will automatically load any available functions, hit enter to have code complete enter that function.

Note that the description we provided of "Current price greater than the previous close" is shown in the tool tip

Next we will add the AND operator to the formula by typing it after the #Bullish function

Note that code complete provides descriptions system operators and functions in the tool tip

We will now add another new function

This function will be for Volume to be greater than "x" times an "n" bar average of volume (V>x*AVGVn), we will create parameters to define "x" and "n" and set their default values to 1 and 30. We will also describe what they do. We will describe this function as "Above average volume" and name it "BigVol" and click OK to bring it into our original formula editor window

For more on parameters please see this article. For more on comments and descriptions please see this article.

We now see this function available with not only the offset parameter, but also our X and N parameters

We will now call this function into our formula

We can now use the show formula button to show the long form PCF that is being calculated

We can change the parameter values in the #BigVol function by entering them in parentheses after the function. We will change X to 2 and N to 90 we will not include an offset

Note as you enter in new parameter values their description will be shown in the tool-tip. We have already entered in 2 for the X parameter so this description is for the N parameter

Now that the parameters have been changed we can use the show formula button to see the changes in the long formula

If you need to make changes to the functions you can click on the edit button next to them

This will re-open the editor window for that function, you can also save that function formula to the library by clicking on the hamburger menu and selecting save formula

Finally we will name our PCF that is using the two functions, then click OK

Since we created this True/False formula using the New button once we click OK it is automatically saved to our library, regardless if we apply it to our layout or not

For this example we will select to sort in a new window

Our True/false column has now been applied

If we check our EasyScan condition library we will find it listed there as well

If we select it from that library and choose Edit it will re-open the formula in a condition editor window

Because it is saved to the library we could also load it as a function by clicking the hamburger button and selecting add function from library, lets do so just as an example.

It has been added to our list of available functions but note the only parameter available is the optional Offset parameter. We could correct this by bubbling up those parameters, to do so select edit across from the #BullishwithVolume function

For more information on Bubbling up parameters and another example please see this article

Note that even though the formula was saved with the name "Bullish with Volume" when brought in as a function TC2000 will remove spaces and non alphabetical characters to create a valid function name i.e.  #BullishwithVolume

We will need to declare parameters and use them in the #BigVol function, we could name them X and N just like in the #BigVol function but for this example lets call them Y and Z, we will give the the same description as we assigned in #BigVol, and enter them into its parameters, then click OK

#BullishwithVolume now has those parameters available, lets delete everything from our formula and only call in that function and enter 3 for Y and 252 for Z

Finally lets click the show formula button to confirm everything passed through correctly