This function should be used in the Set Parameters script section because it executes after the Before Simulation and before the Before Test sections.

 

This function is similar to the way that the Script.Execute function will execute "UserCreatedCustomName."   Both the Script.Execute() and this function script.InstrumentLoop() will call a custom script named section to perform tasks.  

 

See the Creating Custom Scripts topic for more information.

 

When this function is used, it will call a "UserCreatedCustomName" that will be able to automatically loop-over all of the instruments in the system's portfolio.  

 

The list for changing an instrument, is a list created by the user.  The script will use those some or all of those symbol when it is deciding to change the state of the instrument.inPortfolio status.  When a symbol match is found, the instrument.DisableTrading function will change the state to False.   Which symbols in a portfolio are removed from trading is dependent upon how the conditional conditional statements are created for matching a symbol in the portfolio with a symbol-name on the list.

 

Syntax:

'  Function calls the Custom-Script created for
'  handling the instrument and or indicator
'  activity state.
script.InstrumentLoop( "anyCustomScriptName" )

 

Parameter:

Description:

anyCustomScriptName

Custom script's name created to perform a task.

 

Example:

'  Custom script adds two numbers together
Print script.InstrumentLoop( "DisableSymbolList" )

 

Returns:

The return will be the execution of the scripts in the custom script name used as the script parameter.

 

Example:

This is an example of how a custom script can be created to disable symbols in a portfolio from being used by the system.  The name of the custom script created is "iOnOff_Instrument."


'  ==============================================================
'  Control Active Symbols
'  iOnOff_Instrument - SCRIPT START
'  ==============================================================
'  This Script Section Disables specific Instruments in a
'  Portfolio.  It then  Display Current Date, Symbol, and its
'  Trading State condition.
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Create Temp Variables for Print & Debug Stepping Display
VARIABLES: iDate, iInPortfolio   Type: Integer
VARIABLES: sSymbol               Type: String
'  --------------------------------------------------------------
'  Temp Print & Debug Assignments
iDate = instrument.date
sSymbol = instrument.symbol
iInPortfolio = instrument.inPortfolio
'  --------------------------------------------------------------
'  Display the loaded instrument.
PRINT instrument.date, instrument.symbol, instrument.inPortfolio
'  If the symbol is listed here, turn make it InActive
If ( sSymbol = "CD" ) OR ( sSymbol = "DJ" ) THEN
 
  '  Remove From Portfolio
  instrument.DisableTrading
 
  '  Example code in a custom script called
  '  "iOnOff_Instrument"
  iDate = instrument.date
  sSymbol = instrument.symbol
  iInPortfolio = instrument.inPortfolio
 
  '  Display Current Date, Symbol, and its Trading State
  PRINT instrument.date, instrument.symbol, instrument.inPortfolio
ENDIF
 
'  Add a Space between each symbol
PRINT
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  ==============================================================
'  iOnOff_Instrument - SCRIPT END
'  Control Active Symbols
'  ==============================================================

 

Returns:

System's Portfolio has four symbols:

AD, DJ, ED, CD


Prior to this custom script running, all of the instruments were active and would load if this script had not been run.

 

Calling Script Name: Set Parameters

Output shows the Date when the instrument's inPortfolio property  was changed.

 

instrument.inPortfolio at start, shows all the symbols will show TRUE.

When the instrument.DisableTrading is executed, it will change to FALSE.


Date:              Symbol   inPortfolio-State

20140402     AD         1

 

20140402     DJ         1

20140402     DJ         0

 

20140402     ED         1

 

20140402     CD         1

20140402     CD         0

 

 

Links:

Script, Script Functions, Script Properties

See Also:

 


Edit Time: 9/21/2020 3:03:37 PM


Topic ID#: 95

 

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