Companion function to the software's System Object.  It is used to allow access to scripts and values in systems other than the system in which this function is being executed.  Most often this function is used in a Suite where a GSS system (a system with the same name as the Suite name) that is intended to access information in other systems in the Suite.  

 

It gets access to the information in other systems in the Suite when it is called using the index of the system where it wants to access information.  It gets access to information by bringing that system into context so the system executing this function can access information using the "alternateSystem" object prefix.  When a system is brought into context any of the functions or properties of that system become available from within a system where SetAlternateSystem is being used.  Property and function names used are identical to those listed in the System Object.

 

Global Suite System (GSS) are where this function is handy so as to allow information to pass between the system running in the GSS container.

 

Syntax:

test.SetAlternateSystem( systemIndex )

 

Parameter:

Description:

systemIndex

System index number.  When this function is executed it sets the special built-in object "alternateSystem" with a new system by index.

 

System index number is assigned by the order in which systems are added to a Suite.  Index numbers for system begins at zero, which is reserved for the Suite's GSS system, and the index values assigned end at the number value that represents the number of non-GSS systems in the Suite.

 

Trading Blox allows a specific number of scripts for use in a GSS module.  To see which scripts are available, and to understand the order of when those scripts will execute review the Global Script Timing Table.

 

Example - Alternate System Access:

' Loop over the systems in the test.
FOR systemindex = 1 TO test.systemCount
 
  ' Set the alternate system by index.
  test.SetAlternateSystem( systemIndex )
 
  ' Print each system name and available equity
  PRINT systemIndex, alternateSystem.name, alternateSystem.totalEquity
NEXT

Return - Alternate System Access:

Out will display the system's suite index, its system-name, and its total-equity amount.

 

Example - Alternate system with the alternateBroker:

IF inst.LoadSymbol( "F:GC", 1 ) THEN
 
  test.SetAlternateSystem( 1 )
 
  IF inst.isPrimed AND inst.position = OUT THEN
    alternateBroker.EnterLongOnopen( inst.symbol )
     
    IF alternateSystem.OrderExists() THEN
        order.SetQuantity( 10 )
    ENDIF
  ENDIF
ELSE
  PRINT "Unable to load symbol"
ENDIF

Return - Alternate system with the alternateBroker:

Sets the special built-in object "alternateBroker" with a new system by index.

The alternateBroker object can then be used to place orders for other systems.

 

function to access instruments in other systems in the suite:

Example - Alternate system with the LoadSymbol:

'  ==============================================================
'  _Alternate System Access Example
'  AFTER TRADING DAY SCRIPT - START
'  ==============================================================
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Create Position Margin Header Details
PRINT "t.Date", _
    "t.TotEqty", _
    "altSys.TotEqty", _
    "SysNum", _
    "Symbol", _
    "posCnt"
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Loop over the systems in the suite.
For iSysNdx = 1 TO test.systemCount
  ' Set the alternate system by index.
  test.SetAlternateSystem( iSysNdx )
  '  -----------------------------------------------------------
  '  Access All Systems in this Suite
  '  -----------------------------------------------------------
  '  Clear Position Counter
  iActivePositionCount = 0
  '  -----------------------------------------------------------
  '  Loop over the instruments.
  For iSymbolNdx = 1 TO alternateSystem.totalInstruments STEP 1
    '  --------------------------------------------------------
    '  PROCESS ALL OPEN POSITTIONS
    '  --------------------------------------------------------
    '  Load System Number: iSysNdx & Symbol Number: iSymbolNdx
    iLoadOK = MktSym.LoadSymbol(iSymbolNdx, iSysNdx)
    '  When Symbol Loads,...
    If iLoadOK THEN
        '  Get Position Unit Count
        iPositionQty = MktSym.currentPositionQuantity
        '  Positions with Quantities > 0 Counter
        If iPositionQty > 0 THEN
          '  Count System Active Positions
          iActivePositionCount = iPositionQty + 1
        ENDIF '  PositionQty > 0
    ENDIF '  iLoadOK
  Next '  Symbol_Ndx
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  Send Data to PrintOutput.csv file
  PRINT test.currentDate, _
        test.totalEquity, _
        alternateSystem.totalEquity, _
        iSysNdx, _
        iActivePositionCount
Next ' iSysNdx
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  ==============================================================
'  AFTER TRADING DAY SCRIPT - END
'  _Alternate System Access Example
'  ==============================================================

Result - Alternate system with the LoadSymbol:

When the above Alternate System Access Example is

executed, it will generate a table similar to how

this next image displays its PRINT OUTPUT

information in a spreadsheet.

Alternate System Access Example

Alternate System Access Example

 

Links:

System Object

See Also:

Global Script Timing Table

 


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


Topic ID#: 531

 

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