Trading Blox Basic supports four variable Groups:

Groups:

Use:

Block Permanent (BPV)

Block Permanent Variables are common to all the script section, and are accessible anywhere in the block module when the variables Scope is set to Block.  They can be accessible anywhere in the System, Test, or Simulation if one of those wider Scope ranges is selected.

 

Various BPV Variable Types can be selected (see table below).  None except the Instrument Type is connected to a specific instrument as Instrument Permanent variables are designed.  Instead, they can accept a value from an instrument, but the value will be accessible to all the other instruments as the Instrument loop processes each symbol in a portfolio.

 

When deciding on which kind of variable to use, consider if the value in the variable can be common to all instruments.  If it can, the a BPV will be a good choice.  If it needs to be specific to a specific instrument, then select an IPV.

Instrument Permanent  (IPV)

Instrument Permanent variables are designed to add information to the property information available to each portfolio symbol.  In a sense they create an additional property that can easily be assigned and accessed through simple scripting statements.  

 

IPV group supports a variety of variable types (see table below), and they follow the same rules  instruments observe in the various scripts were they are given context automatically, or are required to be brought into context through a manual process.

 

Select an IPV as a group choice when the information to be contained within the variable will only pertain to that specific instrument.  For example, if you want to set a value for a signal for that instrument alone, then an IPV is a good choice.  However, if the value in a variable pertains to all of the instruments, then a BPV is the better choice.

Parameters

Parameter variables become visible in the user's menu area.  They provide methods for changing the length of a calculation, the value to be applied in a calculation, controls that can influence which areas of a module are allowed to function, and they can be stepped in an attempt to discover how their variation in value influences how a system performs.

 

Parameters are accessible in all script sections.

Local

Local variables are created in a specific script section.  Their scope is isolated to the script section in which they are declared, and are accessible anywhere in that same script section.  

 

When naming a Local variable ensure the same name being declared has not been used elsewhere in the script, or in the System, Test, or Simulation when those scope are employed in the Suite of modules.

 

In simple terms, only use local variable names that are unique and are only needed in that script section.

 

Local variables are not cleared when the script section is executed.  This means to clear the value in a Local variable that can affect a statement before the script section has assigned it a value, the variable in most cases should be cleared.

 

Within these groups there are six standard variable types.  One of which is a special Instrument type that can be created as a BPV and used to access an instrument.  Not all of the variable types are available in all of the groups.  To know which is available where, review the table here and review the links associated with of the variable types and groups.

 

Variables available by Group and Type:

TYPE

Available:

Description:

Boolean

P

This parameter variable type can only be True or False.  When True the value is equal to 1, and it is zero when False.

Floating

B, I, P

Decimal numbers like 1.24 or 3.14159 which are not whole numbers

Instrument - BPV

B

Direct access to instruments is only available in the scripts that allow the instrument object context.  To access an instrument in a script where it doesn't have context it is necessary to use this BPV type so an instrument can be moved into context and made accessible.

Integer

B, I, P

Whole numbers like 1, 200, 582, -5

Money

 

S

 

Variables which hold money.  Internally Money variables are stored in the same way as a floating point variables. Money variables are printed differently and show in the debugger with different formatting.

Percent

P

Default value entered must be as a decimal where 0.10.  When this parameter appears on the main screen page it will be displayed as 10%.  In calculations it will be applied as a decimal where 10% is applied as 0.10.

Price

B, I

Variables which hold price information.  Internally Price variables are stored in the same way as a floating point variables. Price variables are printed according the current instrument's formatting and show in the debugger using that format. Price variables are also unadjusted for any negative value adjustment that may be present because of a negative price series in the instrument's data.

Selector

P

This is a special type of parameter because it can be assigned a list of words that will act as value to allow the user to modify how the scripts operate.  When the list is created, the first word phrase entered will be assigned the value of zero.  Second word phrase will be assigned the value of 2, and each remaining word phrase will be assigned the next available integer value until all have been assigned a value.

 

In operation, the use will select one of the option displayed in a drop-down list of word phrases, or they can select the Step All option enabled when it is enabled.

Series

B, I

All series or arrays store numbers and text value in a series elements.  Each element contains the value it was assigned until it is cleared.  Each element in a series is accessible, or index, by using its referenced location.

 

In simple terms, a series is a list or an array of elements that contain the values of Floating numbers or String Alpha-Numeric characters.  

 

Auto-Indexed series are accessed are reference by the specifying the offset value from the current bar to where that element will be located.  For example, to access yesterday's series element, use a value of 1 as the offset amount.

 

Manually sized series are access an element by its count position within the series.

 

Smallest value of a series is 1, and 1 is always the position location of first element in the series.  Use above information to determine if it is accessed by offset reference, or direct location reference.

String

B, I, P

Characters, or combinations of characters like "Hello", "A", and "November Soybeans."

Legend:

B = BPV

I = IPV

P = Parameter

S = Script

 

Note:

All Parameters, except String Parameters, can be assigned a default value.

All parameters, except String types, can step their values, and can be assigned a stepping priority value to arrange their sequence in how they are to stepped during a test simulation.

Integer Parameters can be enable during program data priming Look-back amount calculations to prevent out of range errors..

 

Notes:

Variables declared using the VARIABLES statement in any of the script section are local to that script except when used in a Custom Script Function.  Local means that script defined variables are only accessible during the script in which they are defined.  This also means you cannot define a variable in an Entry script and then believe you can use it in the Exit script.  When you need cross script access to common variables use an IPV, or a BPV declared variable.  

 

When script declared variables are used in a Custom Script Function, the values in the Custom Script Function will be exposed to the values in the script that called the Custom Script Function.  This ability makes Custom Script Function flexible to use and to gain access to various script section, but it can cause errors when the name of a script declared variable is the same as a variable in the script that is calling the Custom Script Function.

 

Declaring Local variables can be handle in ways similar to what is shown in the examples that follow:

Syntax:

VARIABLES: varname1 [TYPE: type ], varname2 [TYPE: type ] ...
 
varname      Name of the variable.
type         Type of the variable - see table below.

 

Various examples to illustrate how to use a VARIABLES statement:

VARIABLES: someValue TYPE: Integer
'  SomeValue was defined and can be only integer
 
someValue = 10       '  SomeValue is integer and contains 10
someValue = 3.15     '  SomeValue is integer and contains 3

 
VARIABLES: a TYPE: Floating
'  Single VARIABLES statement
 
VARIABLES: a, b, c TYPE: Integer
'  Three variables in single VARIABLE statement
 
VARIABLES: str1 TYPE: String, int1 TYPE: Integer
'  Multiple variables of different types

 

The variable someValue should be declared with a TYPE of a Price when value displays need price formatting:

someValue = instrument.close
someValue = instrument.high - averageTrueRange
someValue = instrument.low * 1.2
someValue = longMovingAverage (where longMovingAverage is a moving average indicator)

 

The variable someValue should be a Floating TYPE in the following situations:

someValue = instrument.close - instrument.close[1]
someValue = instrument.high - instrument.low
someValue = averageTrueRange

 


Edit Time: 9/25/2017 09:09:54 AM


Topic ID#: 249

 

 

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