This script section executes before the instrument data is loaded.  At this stage of testing, Trading Blox Builder enables access to all instruments that will be loaded when the Before Test Script section is operating.

 

Note:

In a stepped simulation, the threads are locked.  This is done so the script sections"

Set Parameters

Before Test

After Test

In each thread each thread will complete without overlap from a different thread.

 

This script section enable or disable one or more symbols in the portfolio.  Symbols disabled prior to loading, will not be loaded in an inactive state.  When an instrument is not loaded, the computer's memory space will remain available.  The time to load the data, would be used.  In simple terms, reducing the active symbols in a portfolio reduces the memory required and the time it would take to load the symbols and calculate the systems indicators.  

 

Set Parameters script executes:

After the Before Simulation script and ahead of the Before Test script.

Before the system's indicators are computed..

This script section support the script.InstrumentLoop function that will automatically loop through all the symbols in the portfolio.

Enabling and Disabling indicators and custom IPV and BPV series disabled will reduce some test time.

Setting the Type Value of an indicator, before the indicator is computed.  i.e. Changing from a SMA of the Close to an SMA of the Open can also be handled in this section.

 

How to change an instrument's ability to Load:

The process uses this function when called from this script section.

  script.InstrumentLoop( "anyCustomInstrumentScriptName" )

 

When called from another script section, the example in the instrument.DisableTrading topic can be used.

 

Note:

Regular Indicators that use Price or Volume as a data  source are not recomputed for each stepped test run unless an indicator dependent parameter changes value.

Calculated Indicators and Regular Indicators that use another indicator as the source data, are still recomputed for each test.

Multi threaded testing computes indicators for each thread separately, which uses memory and time as initial overhead.

 

When the Set Parameters script section isn't displayed in a blox, the following sequence of steps will add it after the script that is right-clicked to enable an additional script section to be loaded.

Click to Enlarge; Click to Reduce.

Add Set Parameters Custom Script Section Steps

The Set Parameters script section will always run after the Before Simulation script is finished executing.  It will also run before the Before Test script section is run.

 


Variable Portfolios:

Before Trading Blox Builder can run a test, it needs to know all the market symbols allowed to trade.  Usually, each symbol in the portfolio loads into memory.  Every symbol in memory is available for order generation analysis.  The key to creating a variable portfolio is to prevent some symbols from being loaded into memory.  

 

At the beginning of a test, the Before Simulation script section initializes all the test settings.  All the portfolio symbols are recognized and enabled so they can load into memory.  After the Before Simulation script section, this Set Parameters script section will run when scripting is entered its script area.

 

The Set Parameters script section has access to all the symbols in the portfolio.  It uses a Custom Script section that can change a symbol from being available to trade to being unable to trade.

 

A symbol with its instrument.inPortfolio property value set to TRUE is allowed to trade.  Changing the property to False by applying the instrument.DisableTrading function stops the symbol from trading.  It can also reverse that condition by assigning the instrument.inPortfolio property to TRUE.


 

These indicators and series can be set as enabled or disabled by default in the Trading Blox Builder Basic editor.

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"

 

This script detail is placed Set Parameters script section so the custom script "iOnOff_Instrument" can be executed when the Set Parameter script section executes.

 

Notes:

Creating a specific set of instruments from a portfolio that has all the possible instrument you wish to examine should be used as the Symbols Supply.

Before using the Symbol Supply portfolio, use the system.SortInstrumentList(5) to ensure all the symbols are in alphabetical order.  This also true for target list of symbols that have been created.

Specifying which symbols in the Symbol Supply are needed for a test should be placed in a normal portfolio set file, or an independent text file that can be accessed and used as a stepped process to identify which symbols should be allowed, and which symbols should be blocked from trading.

Adding a Selector Parameter with the names of the variable portfolio in use can be used to determine which target-portfolio symbols are to be used for the selected portfolio name.


'  ==============================================================
'  Control Active Symbols
'  Set Parameters - SCRIPT START
'  ==============================================================
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Set Parameters script runs after parameters
'  are set For the test run, but before the
'  indicators are computed.
'  --------------------------------------------------------------
'  This script Allows For:
'     1) Setting custom parameter values TO
'        be used when computing indicators.
'     2) Enabling AND Disabling indicators
'        AND custom IPV AND BPV series TO
'        save time AND memory
'     3) Setting the Type Value of an
'        indicator, before the indicator
'        is computed. Changing from a
'        SMA of the Close TO an SMA of
'        the Open, For example.
'  --------------------------------------------------------------
'  Runs a custom script For each enabled
'  instrument in the portfolio. Sets the
'  default instrument object.
script.InstrumentLoop( "iOnOff_Instrument" )
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  ==============================================================
'  Set Parameters - SCRIPT END
'  Control Active Symbols
'  ==============================================================

 


In this example, the Symbols to disable are hard coded into the conditional:

If ( sSymbol = "CD" ) OR ( sSymbol = "DJ" ) THEN

 

That can be changed by adding a list of symbols into a string series.  If all the symbols in the series are enable for trading, then any symbol not in the series can be disabled from loading into memory.  The following example scripts will automatically loop all the instruments in the portfolio so they can be trading-disabled, or allowed to trade.

 


'  ==============================================================
'  Control Active Symbols
'  iOnOff_Instrument - SCRIPT START
'  ==============================================================

' script.InstrumentLoop( "iOnOff_Instrument" )
'  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:

SetSeriesEnable,

See Also:

Before Simulation, Before Test


Edit Time: 12/27/2020 1:11:13 PM


Topic ID#: 94

 

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