Writing Your Own Functions

 

TradingSolutions comes with over 250 built-in functions. However, there may be many situations in which you want to write your own functions. You may have your own financial indicator that you want to test. Or, you may have a series of functions that you perform frequently from which you only need the final value.

 

TradingSolutions provides two different ways you can create your own functions:

·      TradingSolutions Formula

This method allows you to combine existing functions in a new formula using a point-and-click interface.

&  For a step-by-step introduction to this topic, see the tutorial called Writing Custom Functions.

·      External TradingSolutions DLL

This method allows you to use an external DLL to perform the function. All TradingSolutions users can use external DLL’s. However, developing new DLL’s requires the TradingSolutions SDK Add-on.

Creating a New Function

 

image\ebd_ebd224.gif

 

To begin creating a new function, use the Define Functions button in the toolbar or select Define Functions… from the Processing menu. Either of these options will display the Define Functions Dialog, from which you can view existing functions and create new ones. From this dialog, select the New… button beneath the list of functions. This will display the Create a Function Definition Wizard.

Ä    Tip: TradingSolutions uses function groups to separate functions and make them easier to find. When creating a new function, try to place it in an appropriate function group to make it easier to find later. This can either be an existing function group or a new function group that you use just for your own functions.

 

The Create a Function Definition Wizard begins with the Basic Information page. This page allows you to enter the name and description of the new function, along with assign it to a function group.

 

Functions in TradingSolutions have two names – a descriptive name that appears in selection lists and a short name that is used in formulas. For example, a moving average function might have a selection name of "Moving Average" and a formula name of "MA". Also, both names must be unique. This is to help you from having to decide which of three "Moving Average" functions you wanted.

Ä    Tip: Try to name your functions something that will help you to remember what they do. Using a name like "Add Three Numbers" will probably be more useful than a name like "Dan’s First Function" when you go back to use it.

 

In most cases, you will be creating a functions using a TradingSolutions Formula. In this case, the next page in this wizard is the Enter Formula page. This is the page where you actually enter the formula for your new function using combinations of existing functions. This can be a fairly complex process to get used to, but after writing a few formulas, it should become a very intuitive process.

&  For help entering formulas using this dialog, see Formula Entry.

Ä    Note: More complex functions can be created in the Visual C++ programming language using the TradingSolutions SDK add-on. For more information about this add-on, see the TradingSolutions web site.

 

When entering a TradingSolutions Formula, the final pages of the Create a Function Definition Wizard are the Specify Inputs page and, optionally, the Enter Notes page. These pages allow you to verify the order and types of inputs that you will specify when you want to use it. In addition, you can specify any notes about using the function at this time.

 

If you are using an External TradingSolutions DLL, your first step will be to specify the inputs required by the DLL on the Specify Inputs page. Then, specify which DLL to use or develop a new one from the Select External DLL page.

&  For help creating External DLL’s, see Developing External DLL's.

 

&  For more help creating functions, see the help for the Create a Function Definition Wizard.

Modifying an Existing Function

There are two ways to modify an existing function. The easiest way is to actually modify the function itself. To modify a function directly, simply select the function definition you would like to modify on the Define Functions Dialog and press Edit…. This will display the Modify Function Definition Dialog, where you can modify the name, formula, input order, or descriptions.

Ä    Note: Functions that are provided with TradingSolutions are protected from changes. Instead of modifying these directly, you should make a copy and modify the copy.

 

If you would like to modify an existing function without changing the original function, you can create a copy of the function and modify that to suit your needs. For example, if a provided function uses one type of moving average and you would like to use another type, you can copy the function and replace the type of moving average that is being used.

 

To copy a function, begin by creating a new function. As described above, this is done from the Define Functions Dialog by pressing the New… button beneath the list of functions. Then, from the Create a Function Definition Wizard: Basic Information page, press the Copy another Function Definition… button. This will display the Copy Function Definition Dialog, where you can select which function to copy.

 

Once you select a function to copy, your new function will have copies of the formula, descriptions, and notes ready for you to modify. Simply continue through the Create a Function Definition Wizard as you would when creating a new function.

 

&  For more help with functions, see Calculating Values and Financial Indicators.