AlternateBroker is also a Broker object with all the same functions and properties as the standard broker functions and properties.  Use this method when the script does not by default have context for instrument access shown in Blox Script Access.

 

To use the AlternateBroker process the system where the AlternateBroker function are to be applied must first be brought into context.  Context assignment is performed with the test.SetAlternateSystem function using the Suite's assigned system.index value (see line #4 in Example area).

 

When the alternateSystem object is set to the system number referenced, the AlternateBroker object is automatically sets to the same system.index value.  This dual context-assignment allows orders to be placed for any system from any system, including from a Global Suite System (GSS).  

 

In a GSS system instruments can be looped over and orders placed for any instrument in any or the systems in the suite.  From a GSS, the instrument.symbol needs to be the first parameter used in the LoadSymbol function referenced (see line# 2 in Example area).  This additional system index reference requirement after the symbol is necessary because the GSS has no default instrument context.

 

Here is an example of placing an order for Gold (GC) in System_1.  This function call can be done from a GSS or any other system in the test, and it assumes GC is in the current portfolio for system 1.

 

"Mkt" in the example below is a BPV Instrument variable necessary to bring an instrument into context.

 

Example:

'  Example loads Gold Future contract into the BPV instrument 'Mkt'
If Mkt.LoadSymbol( "F:GC", 1 ) THEN
  '  Set system data access to System-index 1
  test.SetAlternateSystem( 1 )
  '  When the Mkt/Instrument is primed, and
  '  when the Mkt/instrument's position is Flat,...
  If Mkt.isPrimed AND Mkt.position = OUT THEN
    '  Use the alternate Broker Object function
    '  to create an Long Entry On_Open order for Gold
    alternateBroker.EnterLongOnOpen( Mkt.symbol )
    '  If the Long Entry order is created successfully,
    '  and if it didn't get rejected,...
    If alternateSystem.OrderExists() THEN
        '  Set the order quantity to 10-contracts
        order.SetQuantity( 10 )
    ENDIF
  ENDIF '  Mkt.isPrimed AND Mkt.position = OUT
ELSE
  '  Show the Gold Futures file failed to load.
  PRINT "Unable to load symbol"
ENDIF '  Mkt.LoadSymbol

 


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


Topic ID#: 145

 

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