Sorts the series1 based on the values in series2. Only for non auto indexed series. Not available for auto indexed series.

 

Note that the three optional parameters are only optional if the preceding parameter is included.

The following are valid:

SortSeriesDual( series1, series2 )
SortSeriesDual( series1, series2, elementCount )
SortSeriesDual( series1, series2, elementCount, offset )
SortSeriesDual( series1, series2, elementCount, offset, direction )

 

The following is not valid:

SortSeriesDual( series1, series2, direction )

 

Syntax:

SortSeriesDual( series1, series2, [element count], [offset], [direction] )

 

Parameter:

Description:

series1

The series name that will be sorted based upon the values in series2.

series2

The series name that contains the values sorting will use to determine the sort

[element count]

Optional value.  Function default sorting action is to sort all the elements in the series.  When a value is entered, that value determines how many elements in the series are sorted.

[offset]

Optional value. The starting index from which element count goes back for non auto indexed series.  Default value is zero so the function will sort the [element count] specified elements.

[direction]

When parameter is not used, the default sort is in ascending order.

Note:

Positive value sorts the elements in ascending order.

Negative value sorts the elements in descending order.

 

Example:

'  Sort resultsIndex based on the values of the results series.
SortSeriesDual( resultsIndex, results, elementsToSort, elementsToSort, -1 )
     
'  Sort the series element in descending order.
SortSeries( results, elementsToSort, elementsToSort, -1 )

 

This is an example of how a dual series numeric series can be used:

 
'  ==============================================================
'  _SortDualSeries_Example
'  BEFORE TEST SCRIPT - START
'  ==============================================================
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
'  Create Character Spaces for Symbol Padding  
iTxtLen = 5
sPad = ""
 
For x = 1 TO iTxtLen STEP 1
  sPad = sPad + " "
Next '  x
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
'  Determine How Many Symbols to Create
SymbolCount = system.totalInstruments
 
'  Size Series To Symbol Count
SetSeriesSize(Series1, SymbolCount)
SetSeriesSize(Series2, SymbolCount)
SetSeriesSize(Series3, SymbolCount)
SetSeriesSize(Series4, SymbolCount)
 
PRINT
PRINT "Random Seed Value = ", RandomSeed(1)
PRINT
PRINT "--------------------------------------------"
PRINT "GENERATE RANDOM NUMBERS"
PRINT "--------------------------------------------"
PRINT  
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
'  Build Sample Dual Data Series
For x = 1 TO SymbolCount STEP 1
  '  Load Each Symbol in the Portfolio
  Load_OK = Mkt.LoadSymbol( x )
 
  '  Assign Values to Each Series
  Series1[x] = x
  Series2[x] = Random( 0, 30000 ) * 0.001
 
  '  Randomly Convert To Negative Value
  If Random(1, 10) < 5 THEN Series2[x] = Series2[x] * -1
  '  Duplicate Series2 Values in Series3
  Series3[x] = Series2[x]
 
  '  Provide Character Third Column Sort
  sTxt1 = Mkt.symbol
  sTxt1 = sTxt1 + Left(sPad, iTxtLen - Len(sTxt1))
  snum = ""
 
  For y = 1 TO Len(sTxt1) STEP 1
    snum = snum + ASCII(mid(sTxt1, y, 1))
  Next '  y
 
  Series4[x] = AsFloating(snum)
 
  '  Show Assembled Random Character Symbol
  PRINT AsString(x,0), " - ", _
        Series1[x], " - ", _
        Series2[x], " - ", _
        Series3[x], " - ", _
        Series4[x], " - ", _
        sTxt1
Next ' x
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRINT
PRINT "--------------------------------------------"
PRINT "SortSeriesDual"
PRINT "--------------------------------------------"
PRINT
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  PERFORM DUAL SERIES SORTING STEPS
'  Sort Series1 based on the values in Series2
SortSeriesDual( Series1, Series2, SymbolCount, SymbolCount, 1 )
 
'  To Finish DualSort, sort the results of Series2 to Match
'  the sorted index in Series1.
SortSeries( Series2, SymbolCount, SymbolCount, 1 )
 
'  Sort Series4 based on the values in Series3
SortSeriesDual( Series4, Series3, SymbolCount, SymbolCount, 1 )
 
'  To Finish DualSort, sort the results of Series4 to Match
'  the sorted index in Series1.
SortSeries( Series3, SymbolCount, SymbolCount, 1 )
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  SHOW SORTED RESULTS
'  Display Column Titles
PRINT "Count", " - ", "GrpNdex", _
        " - ", "Data 1", _
        " - ", "Data 2"
'  Display Sorted Series2 and the Aligned Series1 Index
For x = 1 TO SymbolCount STEP 1
  '  Get the series reference
  sNum = AsString(Series4[x], 0)
 
  Load_OK = Len(sNum)
  sTxt1 = ""
 
  For y = 1 TO Len(sNum) STEP 2
    sTxt1 = sTxt1 + mid(sNum, y, 2)
  Next '  y
 
  PRINT AsString(x,0), " - ", AsString(Series1[x], 0), _
        " - ", AsString(Series2[x], 3), _
        " - ", Series4[x], _
        " - ", sTxt1 )
Next '  x
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  ==============================================================
'  BEFORE TEST SCRIPT - END
'  _SortDualSeries_Example
'  ==============================================================

 

SortSeriesDual Usage Example The the link on the left to access the above example that is a posted in the Trading Blox Marketplace section.

 

Returns:

Sorted series based upon the values in the series 2.

 

Links:

SortSeries

See Also:

Series Function

 


Edit Time: 9/18/2020 11:38:03 AM


Topic ID#: 572

 

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