Finds the sum of the series.  This function will not sum or total a sequence of comma limited values or expressions.  For a non-array values totaling function see SumValues.

 

This example shows the use of the common auto indexed series. For information on using functions with non auto indexed series review Series Functions.

 

Syntax:

Sum( series, bars, [offset] )

 

Parameter:

Description:

series

name of the series

bars

number of bars over which to find the value

offset

number of bars to offset before finding the value

 

Example:

'  --------------------------------------
'  Auto-Indexed Series Example
'  Example Shows Sum of Bars 11 to 20
'  --------------------------------------

' Find the sum of the 10 closes starting 20 bars ago
sumCloses = Sum( instrument.close, 10, 20 )

 

'  --------------------------------------
'  Manually Index Series Example
'  Example Shows Sum Values in Series

'  for values shown.
'  --------------------------------------
'  Set Series Size
iSize = 10
'  OffSet Determines Range
iOffSet = 10
'  Size Manual Index Series
SetSeriesSize(X, iSize )
'  --------------------------------------
'  Loop Through Series
For i = 1 TO iSize STEP 1
  '  Assign Index value
   X[i] = i
Next '  i
'  --------------------------------------
'  Sum Value of X[] Series
SumOfX = Sum(X, iSize, iOffSet )
'  --------------------------------------
PRINT "Total Value of Series = ", SumOfX
'  --------------------------------------
'  Sum Value of X[] Series
SumOfX = Sum(X, iSize-8, iOffSet )
'  --------------------------------------
PRINT "Total Value of Series = ", SumOfX
'  --------------------------------------

Returns:

Function returns the Sum or Total of the series elements specified.

1  =  1.000000000  SumX =  1

2  =  2.000000000  SumX =  3

3  =  3.000000000  SumX =  6

4  =  4.000000000  SumX =  10

5  =  5.000000000  SumX =  15

6  =  6.000000000  SumX =  21

7  =  7.000000000  SumX =  28

8  =  8.000000000  SumX =  36

9  =  9.000000000  SumX =  45

10  =  10.000000000  SumX =  55

Total Value of Series =  55

Total Value of Series =  19

 

Links:

 

See Also:

Series Functions

 


Edit Time: 9/25/2017 09:09:54 AM


Topic ID#: 592

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software