Custom function is a procedure or a function that calculates or transforms data by custom algorithm.
All custom functions are global within the repository and are available for use in all time series databases in the desktop and web applications.
To create a custom function, use the IForeMethods.Add.
On creating a custom function consider the value of the Type parameter to determine method type (arithmetic, pointwise or series). If the custom function is of series type, it handles all selected series simultaneously. One output series containing calculation results is added to the workbook. On specifying parameters of a custom function in the Parameters for dialog box the Result series corresponding to the output series is available.
NOTE. Custom functions can be created only in the desktop application.
In the child-modeling container, custom functions are always calculated in the series mode. All parameters specified in the Parameters For dialog box are recognized automatically. If data series are used in calculation, the data series type should be of the ITimeSeries type. To return calculated values of the function the data of the ITimeSeries type should also be used.
Sub MyFunc(Input: ITimeSeries; Output: ITimeSeries; Coef: Double);
Function MyFunc1(Input, Input1: ITimeSeries; Coef: Double): ITimeSeries;
If the custom method is arithmetic or pointwise, the function that returns the data of the ITimeSeries type should be used as the custom method.
On calculating method for several series the calculation is performed for each series individually. The series with results for each calculated series is added to the workbook.
Use items on the Calculations ribbon tab to apply custom calculation function to the time series. Item location depends on method settings:
If the custom method category matches the category of standard calculation method, the custom function is displayed in the standard menu on the Calculations ribbon tab. For example, a method which has Arithmetic category is included in the menu of the button of the same name.
If the custom method category differs from categories of standard methods, the Custom Functions button containing the submenu with the custom method category name is added to the Calculations ribbon tab. For example, for the method with the My Functions category in the menu of the Custom Functions button the My Functions submenu containing the custom method is added.
If the category is not specified for the custom method, it is included in the menu of the Custom Functions button on the Calculations ribbon tab.
If method calculation requires some additional parameters to be entered, the Parameters For dialog box opens.
After applying the custom function a series with named <Method_name>(<Explanatory_Series_List>) type, containing calculation results is added to the workbook.
See also:
Working with Calculated Series | Setting Up Calculation Method Parameters