|
Accessing System Portfolio Instruments |
Top Previous Next |
|
There are times when you would like to access the properties or indicators of instruments in the system's portfolio. You can use the instrument's LoadSymbol function to set an instrument variable to a particular instrument in the portfolio by numeric index.
Example: 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. portfolioInstrument.LoadSymbol( index )
' Print out the file name. IF portfolioInstrument.InPortfolio THEN PRINT "Portfolio contains: ", portfolioInstrument.symbol ENDIF
NEXT
This code uses the system's totalInstruments property and an index to loop over the instruments in the system's portfolio.
The code assumes that a Block Permanent Variable of the type Instrument has been created with the name "portfolioInstrument". |