SetParametersMethods

 

This script section executes before instrument data is loaded.  This means it can change which instruments will get loaded during the Before Test Script section.

 

This script section can enable, disable one or more symbols in the portfolio.  Symbols that are disabled, will not be loaded in their inactive state.  When an instrument is not loaded, the data it would have consume 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.  

 

The 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.

 

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.

 


'  ==============================================================
'  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 defining a list of symbols the custom script can use to learn what needs to be disabled.

 


'  ==============================================================
'  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: 6/20/2020 3:49:50 PM


Topic ID#: 701

 

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