LoadSymbol

Top  Previous  Next

Sets an instrument variable to a particular instrument. The instrument can be in the portfolio or not, and the instrument can be set using the symbol, the type:symbol, or the index.

 

Recommended that all instruments to be loaded are loaded once in the Before Test script, so that these instruments are set to the correct date when they are used. Subsequent calls to this function in the test will not reload the instrument, but just set the variable accordingly.

 

Syntax

 

LoadSymbol( symbolSpecifier [ or symbol ] [ or index ], [system index] )

 

Parameters

symbolSpecifier

 

the symbol for the instrument with an optional market type prefix like "F:GC" or "S:IBM"

 

Valid Prefixes:

   'F:' - Futures

   'S:' - Stocks

   'FX:' - Forex

symbol

 

the symbol of the instrument like "S" or "AUDCAD"

index

 

the index in the current portfolio

systemIndex

 

the optional system index for the instrument to load.

 

 

 

returns

 

TRUE if the load was successful

 

Examples

 

Create a Block Permanent Instrument Object Variable called tempInstrument.

 

VARIABLES: instrumentCount TYPE: Integer

 

' Get the instrument count.

instrumentCount = system.totalInstruments

 

' Loop printing the symbol for each instrument.

FOR index = 1 TO instrumentCount STEP 1

 

   ' Set the portfolio instrument.

   tempInstrument.LoadSymbol( index )

 

   ' Print out the file name.

   PRINT "Portfolio contains: ", tempInstrument.symbol

 

NEXT

 

Create a Block Permanent Variable called crudeOil.

This example assumes that the "CL" symbol is of the same type as the portfolio being tested:

 

' Load the data for crude oil into the instrument

IF NOT crudeOil.LoadSymbol( "CL" ) THEN PRINT "Could not load CL"

 

 

While this example makes it explicit, that "CL" is of type Futures. It is defined in the Futures Dictionary, and the data is in the Futures Data Folder.

 

' Load the data for crude oil into the instrument

IF NOT crudeOil.LoadSymbol( "F:CL" ) THEN PRINT "Could not load CL"

 

 

Here we are loading a market index which could be used to validate market trends before putting on a position. The symbol of this instrument is "DJIA" and it is a stock.
 

IF NOT dowJoneIndustrials.LoadSymbol( "S:DJIA" ) THEN PRINT "Could not load DJIA"

 

 

 

To check if a loaded instrument is part of the system's portfolio, check if the instrument.priorityIndex > 0. If it is greater than zero, then it is part of the portfolio.