Data Scope

Trading Blox Builder variables, indicators and parameters can all have various scope settings.  The scope of a variable, in programming terms, determines the range, or data-reach and data-access to information where that data-name is located.  Data-Scope can restrict, or expand the access range of data information.  Scope's simplest meaning determines where information can be referenced or changed.

 

In Trading Blox, different types of variables can have different types of scope.  Variable scope is established in the blox where it is created.  To set the scope of a data item, click on the Scope's drop-down arrow when the setting needs to be different that the default Block setting.  Block setting means that data in the variables is a local limited variable.  This means it is only accessible to the script information in the blox where the variable is declared.  Other Scope setting can increase the range of a variable.  Not all variable types have the same number of scope-range options.  All the settings other than the Block option increase the range of the variable beyond the block module.  

 

A Block Scope setting of a declared variable is the most narrow or limited range available.  There is an the exception.  The creation of a script statement Declared Local-Variable.   All Local-Variables are variables that are not created using any of the built-in variable-type editors.  Local-Variables are declared using a TYPE function that is scripted into the script code area to create variables that will only be available to the script area in which they are displayed.  These script created variables do not have any of the initialization features built-into the BPV & IPV variables.  This means that every Local-Variable must be initialized in an area of the script writing area that is ahead of where they are that variable will be referenced in a later area of the script section.

 

Local-Variables do not work as fast as BPV variables.  When the the need to reference a working variable will be in a repetitive structure like a loop or sorting operation, a BPV variable would be a better choice.

 

Custom Functions:

When a script section calls a user created function, the Local-Variables in the calling script and in the called user created function are accessible.  This happens because the process of calling a user created custom function blends the calling script information with the custom user function script code so that each will have access their information.

 

Changing Scope:

Setting a variable's scope to something other than to Block scope allows the variable to be used in other blox in the system.  However, the other blox needs to have a variable with the same name, and if it is an IPV variable, it should be defined as external.

Click to Enlarge; Click to Reduce.

Block Permanent Variable Creation Example

Only IPV and BPV can be defined as External.  

 

IPV -- Instrument Permanent Variables:

Block

You can only use this variable in the scripts that are in the block.

System

You can use this variable in any block in the System by declaring the variable as External in the other blocks.

Simulation

Same as System scoped except the value is not reset for every test (parameter run).

Notes:

To use a System or Simulation scoped IPV in another block, use the variable's "Defined Elsewhere" so the IPV of the same name in the other block will be able to access and change data.

 

BPV -- Block Permanent Variables:

Block

You can only use this variable in the scripts that are in the block.

System

You can use this variable in any block in the System.

Test

You can use this variable in any block in the Test.

Simulation

Same as Test scoped except the value is not reset for every test (parameter run).

Notes:

To use a System, Test, or Simulation scoped BPV in another block, define an external BPV of the same name in the other block.

 

Parameters:

Block

You can only use this parameter in the scripts that are in the block.

System

You can use this parameter in any block in the System

Simulation

You can use this parameter in any block in the Test.

 

Indicators:

Block

You can only use this indicator in the scripts that are in the block.

System

You can use this indicator in any block in the System.

Notes:

To use a System scoped Indicator in another block, define an external IPV Series of the same name in the other block.

 

All variables dialog created parameters and indicators are reset between every test run during a multi-stepped parameter test, and it happens just before the Before Test script is executed.  An exception to this data refreshing is allowed when the variable is set to the Simulation scope reference.

 

IPV and BPV variables are reset to their default value, the parameters are set to the next stepped value, and all indicators are recomputed.

 

Setting IPV or BPV variables using Simulation scope will prevent the values from being reset to the default value. This can be useful when keeping track of a value over the course of many stepped tests, or when loading external data in the Before Simulation script.

 

Because all values are reset just before the Before Test script, the Before Simulation script has no access to indicators or parameters, as they are not set yet. Any IPV or BPV that are set or loaded in the Before Simulation script will be reset to their default value unless they are defined as Simulation scope.

 

None of the script created Local-Variables are automatically initialized during a stepped test unless the script area where the Local-Variables are located have supporting script statements that will initialize the Local-Variables ahead of when they will be referenced.

 


Edit Time: 4/15/2018 9:32:40 AM


Topic ID#: 248

 

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