Trading Blox Builder variables, indicators and parameters can use various scope settings.
Being able to access data where it is needed, can help the other blocks in a system be more capable without them having to create the same processes meeded to obtain the data. When a variable's Scope setting enables access outside of the block were it is created, the data in that variable can be used and changed as processing logic dictates.
Trading Blox provides data variables for different types of features. Each data type can have some of the same types of scope. Each Block variable created will have the same scope setting Block by default, unless the programmer selects a different scope access range.
Trading Blox scope settings determine where data can be restricted or available. Data can be limited to the Block where the scripting creates the information when the Scope Setting = Block. When the variable Scope Setting is Scope = System, data can be accessed by other blocks in the same system. A variable Scope Setting = Test, enables data to be accessed by any of the system Blocks in the same Testing Suite.
A Block that does not create data creates a Variable name defined in a different System Block. The "Defined Elsewhere" option will enable data from the variable name's primary Block to be accessed by the Block where the "Defined Elsewhere" option is enabled.
Accessing data using the Scope Setting process provides more Block capability during a test. The benefit is the ability to get data from other Blocks or systems in the Suite. This feature removes the burden of duplicate programming to obtain already available data in the system or testing suite.
BPV -- Block Permanent Variables: |
|
---|---|
You can only access this variable in the scripts that are in the block. |
|
You can access this variable in any block in the System where the same name is created using the Defined Elsewhere option. |
|
You can access this variable in any block in the Test using the Defined Elsewhere option. |
|
This scope setting enables the value of the variable to be the same value during a multi-step test where threads will run their own test in each of the threads where a test is executing. |
IPV -- Instrument Permanent Variables: |
|
---|---|
You can only access this variable in the scripts that are in the block. |
|
You can access this variable in any block in the System by declaring the variable as External in the other blocks where you wish to have access to the variables information. |
|
Note: The Simulation Scope setting is no longer available because the selection of System Scope, is the same as Simulation Scope. When another block needs to access a variable's value it must use Defined Elsewhere option in the other block's creation dialog. |
This setting will prevent the Parameter's value from being changed. When Disabled is selected, the displayed field will be locked.
A parameter that is disabled will provide the displayed value to indicators and script sections where the parameter's value is used. This means, that all scripts and indicators will still have access to the value the parameter represents. |
|
You can only access this parameter with scripts that are contained in the same block. |
|
You can access this parameter from in any block in the System |
|
You can access this parameter from any block in the Test. |
You can only access this indicator in the scripts that are in the same block. |
|
You access this indicator in scripts that are in any block in the same System. |
|
Note: To access a System scoped Indicator in another block, define an external IPV Series of the same name in the other block. |
All Local-Variables are user defined variables that are limited in scope to the script section where they are defined.
This means, a Local variable defined using the VARIABLES: and Type: functions at he beginning and near the end of the statement and have script Item-Names, are a Local-Variable.
The variable names you use can be any name that is not a Trading Blox Builder Keyword.
' This Example shows how to Create Local Variables ' Each line creates a different type of variable ' Variable types must all be the same type.
Local Variables are do not automatically initialize to a Zero or any other value. Before using a Local Variable, consider creating an initialization step so the process you use doesn't get unexpected results.
' Initialization Example:
Local-Variables are not as fast as BPV variables. If you have a process where there are many iterations of a local variable, a BPV will enable those iterations to be performed faster than a local variable. |
Setting a variable to Block scope limits the information in that variable to the block were is it defined. When the scope is Not Block scope, changes where else the data in that variable will be available to 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.
Only IPV and BPV data types can be defined as an External Reference where the Defined Elsewhere option is used to create access to an IPV or a BPV data variable's value.
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 is the same and it 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 statement value assignments that will initialize the Local-Variables ahead of when they will be referenced.
When a script section calls a user created custom function, the Local-Variables in the calling script and in the custom function are accessible by both locations. This happens because the process of calling a user created custom function blends the calling scripts with the calling scripts environment so that both the calling script section Local Variables and the Local Variables in the custom user function code scan use information in both locations.
Variables scoped Test can now enable or disable the resetting the BPV and IPV variables to default values before a test step in a multi-step test. Historically, the resetting to a default value of these variable was always forced to happen before the next stepped test was performed.
As you might know, in the past use of the Simulation/Test Scope setting would serve two purposes. It provided a scope definition that allowed broad access, and its second process was to suppress the reset before each test.
Trading Blox Builder has now separated these to concepts, so you can set the scope separately from this reset process by changing the status of the "Reset Before Test" option in the dialog where that variable is created. Keep in mind as we talk about variables and values and scopes, each thread gets it’s own set of variables. This means a simulation variable is only visible in the thread were it is created for the step test.
We also now have “Simulation MT” scope, which is a simulation variable that is designed for multi threaded stepped testing. When this scope option is selected, it will follow the setting determined by the "Reset Before Test" option is enabled so same value is available to all thread-steps in the Multi-Step Test.
By default all variables (other than Simulation/Test) are reset to their default before each stepped test in the Before Test script section. This allows each step of the test to start from the same value for all the data variables where the "Reset Before Test" option is enabled.
BPV’s can be Block, System or Test scope. Each of those scope ranges can reset to default before each test or not.
The special type of Simulation MT is a test scoped variable that is accessible across all threads.
The IPV’s can be Block or System scope, again resetting or not. There is no test or simulation scope for IPV’s.
Each thread creates a complete copy of all the systems, blocks, variables, and indicators. So each thread runs totally independent of other threads. There is no way to share an IPV across multiple threads.
For historical clarity, in the past the concept of “Simulation” IPV was really just a system scope that did not reset before each test. So we can still do that now, no change there.
The old and now deprecated “Simulation” BPV was defined as “Test” scope and no reset to default between tests.
The old and now deprecated “Simulation” IPV was defined as “System” scope and no reset to default between tests.
In Trading Blox Builder versions before 5.4.1.x used the scope option: Simulation, Trading Blox Builder will automatically disable the "Reset Before Test" option on the variables where their scope setting shows Simulation. All other variables that do not have the Simulation scoped option will have the "Reset Before Test" check-box checked when the block is used in versions 5.4.1.x and later. This action is taken because the previous Simulation scope option is no longer available.
Previously, a Simulation Scoped variable could reset before each test, and a block scoped variable can suppress the reset before each test and keep the value from the prior test.
Edit Time: 3/18/2021 7:07:39 PM |
Topic ID#: 248 |