Sorts the series in ascending and descending order.  Will sort a limited part of the series any where in the series.

 

Can only be use only with non-auto indexed series.  

 

Auto Indexed series must always be kept align with their indexing method.  

BPV Auto-Indexed series are aligned with test.currentDay.

IPV Auto-Indexed series are aligned with instrument.bar.

 

Syntax:

SortSeries( seriesName, [element count], [offset], [direction] )

 

Parameter:

Description:

seriesName

The series name to be sorted.

[element count]

Optional function value.  When omitted, the default is to sort all the elements in the series unless a specified number of elements is entered into this field.   When a value is entered, that value will specify how many elements to sort.

[offset]

Optional function value.  When omitted, the default is to sort all the elements in the series.

 

When a value is entered into the optional "element count" field, the value entered in this field will be the starting index from which element count will use to start the optional "element count" number of elements to sort.  This means when the intent is to sort the entire series without any exclusions the value entered into this area should be the same as "element count" value.

[direction]

Optional function value.  The default, or no entry in this field, is to sort the elements in an ascending order.

Note:

A positive value sorts the elements in an ascending order.

A negative value sorts the elements in a descending order.

 

Example - 1:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  WtFactors = Manual, or Non Auto-Indexing Series
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Adjust Series Element Count
SetSeriesSize( WtFactors, 3)
'  Get Series New Size
PRINT
PRINT "Show Series Size"
PRINT "Series Size = ", GetSeriesSize( WtFactors )
'  Assign Zero to all the Element in the series
SetSeriesValues( WtFactors, 0)
 
'  Assign Weight Factor to Series
WtFactors[1] = 0.30
WtFactors[2] = 0.40
WtFactors[3] = 0.30
 
PRINT
PRINT "Unsorted Series"
For Ndx = 1 TO 3 STEP 1
PRINT "WtFactors[" + AsString(Ndx,0) + "] = ", WtFactors[Ndx]
Next '  Ndx
 
'  Sort Series in Ascending Order
SortSeries( WtFactors)
 
PRINT
PRINT "Series Sorted in Ascending Order"
For Ndx = 1 TO 3 STEP 1
PRINT "WtFactors[" + AsString(Ndx,0) + "] = ", WtFactors[Ndx]
Next '  Ndx
 
'  Sort Series in Descending Order
SortSeries( WtFactors,3,3,-1)
 
PRINT
PRINT "Series Sorted in Descending Order"
For Ndx = 1 TO 3 STEP 1
PRINT "WtFactors[" + AsString(Ndx,0) + "] = ", WtFactors[Ndx]
Next '  Ndx
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return - 1:

Show Series Size

Series Size =  3

 

Unsorted Series

WtFactors[1]        =  0.300000000

WtFactors[2]        =  0.400000000

WtFactors[3]        =  0.300000000

 

Series Sorted in Ascending Order

WtFactors[1]        =  0.300000000

WtFactors[2]        =  0.300000000

WtFactors[3]        =  0.400000000

 

Series Sorted in Descending Order

WtFactors[1]        =  0.400000000

WtFactors[2]        =  0.300000000

WtFactors[3]        =  0.300000000

 

Example - 2:

' Now sort the results series.
SortSeries( results, elementsToSort, elementsToSort, -1 )

 

Links:

SortSeriesDual

See Also:

Series Functions

 


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


Topic ID#: 571

 

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