Global Suite System

Top  Previous  Next

The global suite system is a special type of system. If a system has the same name as the suite, it will be by definition a Global Suite System.

 

The scripts attached to this global suite system will be processed in a particular order: before the others for the before scripts, and after the others for the after scripts.

 

The following "day/bar" scripts can be used in a GSS:

       Before Simulation,
       Before Test,
       Before Trading Day,
       Before Bar,
       Before Order Execution
       After Bar,
       After Trading Day,
       After Test,
       After Simulation

 

The following "Order" script:

       Entry Order Filled,
       Exit Order Filled,
       Can Add Unit,
       Can Fill Order

 

For the above "Order" scripts, the default system, default instrument and default order context is taken from the system that originated the order. This is different from the non orders scripts, for which the default system is the GSS, and the default instrument is null. The order object is null by default, but can be valid after a call to the alternateBroker function. Use the alternateSystem.OrderExists property to check if the order is available for access.

 

The Global Suite System has a system index of 0, and a system name of "Global Parameters".

 

Use system.IsGlobalSuiteSystem property to check if the system is a Global Suite System, if this is important. Note that for order scripts, the system will be from the system originating the order, so this property will return false. In the non order scripts, the system is the actual GSS, so this property will return true. The GSS does not trade, so there is no instrument list, no positions, and no equity curve. But BPV's and IPV's can be created, and accessed using the SetAlternateSystem and SetAlternateInstrument functions. In this way the GSS can be used as a global storage location for overall control and computation of test level variables.

 

For cases where the physical location of the script, such as system, is important, use the Block object properties. An example might be when a block is used in both a GSS and regular system, and uses an order script to process orders. The order script will be called twice, once in originating system and once in the GSS. Checking if the block.systemIndex will indicate if the script is really in a GSS.

 

 

The Net Risk block in the Blox Marketplace is a good example of how to loop over all instruments, in all systems, and compute a suite level value for each market.

 

PRINT

PRINT test.currentDate

 

totalRisk = 0

 

' Loop over all the instruments that are used in this test. Includes all systems and all support forex conversion markets.

FOR testInstrumentIndex = 1 to test.instrumentCount STEP 1

 

 ' Get the symbol name.

 PRINT "Getting instrument number", testInstrumentIndex

 suiteInstrumentSymbol = test.instrumentList[ testInstrumentIndex ]

 PRINT "Processing", suiteInstrumentSymbol

 

 ' Get the suite level instrument.

 if suiteInstrument.LoadSymbol( suiteInstrumentSymbol, 0 ) THEN

 

         ' Reset our net position to zero for this instrument.

         suiteInstrument.netRisk = 0

         

         ' Loop over all the systems in the test.

         FOR systemIndex = 1 to test.systemCount STEP 1

         

                 ' Set the alternate system so that we can use the name, or other system properties.

                 PRINT "Setting to system index", systemIndex

                 test.SetAlternateSystem( systemIndex )

                 PRINT "Processing for system", alternateSystem.name

                 

                 ' Load the instrument symbol combo.

                 IF systemInstrument.LoadSymbol( suiteInstrumentSymbol, systemIndex ) THEN

                         PRINT "Loaded", systemInstrument.symbol

                 

                         ' If this instrument is in the portfolio for the system, then check the position.

                         IF systemInstrument.InPortfolio THEN

                                 PRINT "In portfolio for system", alternateSystem.name, "with risk of", systemInstrument.currentPositionRisk

                                 

                                 ' To get the net risk, we use positive for long risk and negative for short risk.

                                 IF systemInstrument.position = LONG THEN

                                         PRINT "Long"

                                         suiteInstrument.netRisk = suiteInstrument.netRisk + systemInstrument.currentPositionRisk

                                 ENDIF

                                 

                                 IF systemInstrument.position = SHORT THEN

                                         PRINT "Short"

                                         suiteInstrument.netRisk = suiteInstrument.netRisk - systemInstrument.currentPositionRisk

                                 ENDIF

                         

                         ELSE

                                 PRINT "Not in portfolio for system", alternateSystem.name

                         ENDIF

                 

                 ELSE

                 

                         PRINT "Unable to load", suiteInstrumentSymbol

                 ENDIF

                 

         NEXT

         

         ' Whether positive or negative, it's still risk.

         suiteInstrument.netRisk = ABS( suiteInstrument.netRisk )

         

         ' Print out the net risk for this instrument.

         PRINT "Net Risk", suiteInstrument.netRisk

         totalRisk = totalRisk + suiteInstrument.netRisk

         

 ELSE

         PRINT "Unable to load", suiteInstrumentSymbol

 ENDIF

 

NEXT

 

totalRisk = totalRisk / test.totalEquity * 100