Creating Summation Function

There is a detailed description of creation of Summation function.

At first:

  1. Use the File menu.
  2. Select New.

    image

  3. Select Function.

Now you can see Code Editor. It's empty.

image

Click with the right mouse button anywhere in the Code Editor window.

image

In the shortcut menu select Properties and enter function name in the field Analysis Technique|Name at the Properties window.

image

Enter the name: "Summation". After filling name field this function name will appear at the end of the list of functions at Browser. Default function Type is DoubleFunction. Summation is Double function so keep this field without changes. We want to write this function on C# so keep field Language without changes too.

image

Click the right mouse button anywhere in the Code Editor window again. Now in the shortcut menu select Parameters. Enter input parameters for this Function. This Function calculates summary of Length last values, passed by Values parameter.

image

To add parameters click right mouse button on the Parameters box and in the shortcut menu select Add Parameter and special form will appear.

image

In this form enter Parameter name, Parameter type, Parameter default value, Parameter description and if necessary mark that parameter is Reference. Than click Save if you want to save this parameter or Discard if you don't.

image

For this function at first enter Parameter name ("Values") and select Parameter type ("DoubleSeries") and than click Save.

image

Than again click right mouse button on the Parameters box and in the shortcut menu select Add Parameter. Now enter Parameter name ("Length") and select Parameter type ("Integer") and click Save.

image

So we filled Parameters box:

image

For this simple function we don't need to use References and Variable Store.

Now enter the code of Summation function into the Code Editor window.

image

At first we need to define the variables and initialize them. Declare sum variable to store resulting summary and set it's default value to zero:

double sum = 0;

To calculate summary of all passed values we need to use loop.

  1. Set integer valiable i to zero: int i = 0;
  2. Set condition when to stop the loop: i < Length;
  3. Set what to do with i after each loop iteration: i++;
  4. Specify the action we need to perform in the loop (in this case we want to add i-th value to the currently counted summary): sum = sum + Value[i].

for ( int i = 0; i < Length; i++ ) sum = sum + Values[i];

Then we move to assigning calculated summary, stored in sum variable to Value variable (the actual value of the function).

Value = sum;

After all listed actions click right mouse button anywhere in the Code Editor window and select Build Analysis Technique. If there are no errors in the Function it will appear in the list of functions at Browser with the green tick. Otherwise Task List will appear. For example if you forgot semicolon it will display in Task List with indication of concrete line and file name with error.

image

When you will find the error and correct it click the right mouse button anywhere in the Code Editor window and select Build Analysis Technique again. If there are no errors in the Function now Task List will be empty and function name will appear in the list of functions at Browser with the green tick.

NeedForTrade Trading Platform
Home
Products
Features
Buy
Downloads
Support
Help
Tutorials
Contacts
Login
Login
Login