Working with Blox

The Blox Basic Editor, explained in more details in the Trading Blox Builder User's Guide, provides total control over the creation, edits,  renaming and the deletion of any blox module.  

 

The purpose of a blox is to influence, or add one or more behaviors to the system where it is included in the System's list of blox modules.  When you create a blox to provide logic to a system, any other system where that blox is assigned will have its behavior changed.  

 

Blox modules are a very powerful convenience in computing terms.  It convenience is made possible because it can be "Built once, but used many times."  This flexibility means that when a blox is modified all the other systems where this blox is included in the system list of blox, will inherent the abilities that blox provides.

 

When you only want the blox you modify to have an affect on a specific system, make a copy of the blox before you create any changes.  This step will allow you to change the name of the modified blox without it affecting any of the other systems where the original blox logic is assigned.  When you change the name of the blox, the previous blox name will still be in the system list of modules.  To add the modified blox, remove the previous version and then add the changed versions.

 

Being able to create a blox once, and then use it in many systems, provides a lot of flexibility in creating systems designs.    It also allows you and others to create a blox and offer it as shared blox in the Blox Marketplace section of the Roundtable Forum .

 

To understand all the features and abilities of the Trading Blox Builder's Blox Basic Editor, review the information in the Trading Blox Builder User's Guide.

 


"Defined Elsewhere in Another Block" option:

Click to Enlarge; Click to Reduce.

Any variable "Defined Externally in Another Blox" Option

 

Almost all blox are entirely independent.   Where this isn't true, is when a blox is created with a variable that has enabled the "Defined Elsewhere in Another Block" option.

 

When this data item enables the "Defined Elsewhere in Another Block" option, only the type setting will be displayed in the blox where the data item is named.  Blox that have this option enabled must also have another blox in the same system that provides the named data item's scope setting and any default initialization value required.  

 

Data items that use the "Defined Elsewhere in Another Block" option, create a dependency that requires another blox to be in the system so the data item's information can be fully referenced for the test to operate successfully.

 

When the dependent blox isn't included, Trading Blox Builder will stop a test and display a message similar to this one at the bottom of the data window that appears:

"I can't run the '<Any Script Name>' script from the Trading Block '<AnyBloxName>'.  The parser can't understand line 1 because variable '<AnyVariableName>' is undefined in this context."

 

This message is reporting the "Defined Elsewhere in Another Block" data item hasn't been fully declared in any of the blox listed in the system being tested.

 

For more information about the "Defined Elsewhere in Another Block" option, review the information in the Data Scope topic.

 


Script Sections:

Each blox can have one, or many script sections.  The names of the script sections in a blox varies by Blox Type.  All the standard scripts section available and their execution timing is explained in this Blox Scripts topic. Custom Scripts can be added and called from a standard blox script.  Detailed information about Custom Scripts and their functions, is available in the Script Object section.

 

Script sections in three of the blox types, will create a blox limitation.  That limitation restricts the system to have only one of each of those block types  in a system's structure.  See the information in Blox System Placements for more information about how blox can be added to a system.  

 

Script sections with scripted statements become active when statements are entered into their section.  Script sections without any statements become inactive are not sequenced during a test.  

 

Scripts that contain statements control how  a blox script section will perform during a Trading Blox Builder suite test.  

Click to Enlarge; Click to Reduce.

Trading Blox Block Attributes

 


Data Scope Range Information:

All script sections can support local variables.  Local variables are added to a script section when they are declared in the script section where they appear.  Local variable scope is limited to the script in which it is declared.  This means that the information in a local variable is unavailable to the same name local variable declared in a different script section.

 

Here is how a local variables can be added to a script section:

Local variables are automatically set to Local to the declared variable's script section.

Local variables are not reset or cleared automatically.  

Assigning values to a Local Variables must be handled by scripting statements.

  '  Local Variable Declaration Examples:
  VARIABLES: iStepNum, iTotalSteps Type: Integer
  VARIABLES: trendRate, trendGain Type: Floating
  VARIABLES: sTextMsg, sFileName   Type: String

 

Local variables are often used to simplify the creation of a working variables that will have no use outside of the script section where they appear.  All local variables need to be cleared, or reset to a default value ahead of the time in which they are used if their previous information might contaminate the results they create.  

 

For example, when a statement section needs to count something, and it steps through a repeating loop structure that counts items, if the local counting local variable at the start of the counting process is not zero, the value of the in that local variable incrementing the value of items counted will not be accurate unless the value at the start of the counting in the local variable is zero.

 

Resetting local variables is simple.  It should always happen before they are used in that script section, unless their previous value is needed in that specific script section.  Placement of the variable clearing statements is usually right after where the local variables are declared, or at least before they are used for the first time in the script's section:

  '  Resetting/Clearing of local variables:
  iStepNum = 0           ' Integer
  iTotalSteps = 0        ' Integer
  trendRate = 0.0000     ' Floating
  trendGain = 0.0000     ' Floating
  sTextMsg = ""          ' String
  sFileName = ""         ' String

 

All variable types can be used with functions and properties as long as the variable type will have context in the script section where it is used.  For example, when an IPV variable is needed in a script section where it doesn't have automatic context, like the Before Trading Day script section, access to an instrument can be made possible using the LoadSymbol function.

 

Scope Range:

Variables:

Descriptions:

Local

Local - Script Declared Only

Local variables are restricted to a local script scope.  Their information is limited to the script section where they are declared.

Block

BPV, IPV, Parameters, Built-In Indicators

Block scope means that the variable's information can be accessed, or changed anywhere in the blox where the variable has context.

System

BPV, IPV, Parameters, Built-In Indicators

System scope allows the variable's information to be accessed or changed anywhere in the system where that variable with the same name and scope is declared.

Test

Test, Parameters

Test scope allows the variable's information to be accessed, or changed anywhere in the test where a variable with the same name and scope is declared.

Simulation

BPV, IPV

Simulation scope is Test Scope, but the values in the variables are retained throughout the simulation.

 


Blox Basic Editor:

Creating, Editing, Copying and Deleting a Blox is performed in the Trading Blox Basic Editor.  A full description of the editor is available in the <%APPLICATION_NAME%> User's Guide topic -> Blox Basic Editor topic.

Click to Enlarge; Click to Reduce.

Trading Blox Block Basic Editor

 

The Trading Blox Builder Blox Basic Editor is accessible in the Builder Editions by pressing F4 or by the Basic Editor menu option in the Editor section of the main screen:

Click to Enlarge; Click to Reduce.

Trading Blox Block Basic Editor Access Menu

 

When the Blox Basic Editor appears, any of the listed blox can be changed in the editing area on the right.  New blox can be added, copied or removed using the menu options at the top of the Basic Editor.

 


Editing Blox Scripts:

Before editing a standard blox installed during a setup or update, it is best to make a copy of the Trading Blox Builder installed blox before you make any changes.  Blox copies must have text that is different from the original blox.  A difference could be a simple number or work added to the original blox.  This name difference will prevent a full installation, or an update installation that contains the name of the original blox from replacing the blox you changed.

 

To create a new Blox module, click on the Blox menu and then select the new Option:

Click to Enlarge; Click to Reduce.

Trading Blox Block Basic Editor New Blox Option

 

When you click "New" this dialog comes up:

Click to Enlarge; Click to Reduce.

New Blox Creation Dialog

Enter a name for the blox, and then select the required Blox Type Options option.

 

Before clicking on the OK button, decide if you want all the default script section, or just the required script section for the selected Blox Type Script.  When the above decisions have been made, click the OK button to create the blox module file.

 


Making Blox Script Changes:

Before Deleting or changing the script in any of the blox module, use the Blox menu System option so you can see where the selected blox is being used.  When a blox is assigned to one or more systems, this menu option will display the names of the systems that will be effected by changes or destruction of a blox module.

Click to Enlarge; Click to Reduce.

Blox - System Where Used List

 

When a blox is assigned to a system, Trading Blox Builder will not allow you to delete that blox.  Instead it will display this warning message letting you know why the blox can't be deleted:

Click to Enlarge; Click to Reduce.

Blox - Unable to Delete Warning Message

 

Clicking on the Blox Renaming option will display this dialog:

Click to Enlarge; Click to Reduce.

Blox - Rename Dialog After Name is Changed

 

To copy an existing blox, click on the Copy option in the Blox Menu Options.  When the dialog appears, select 'Copy' option and then change the name of the blox so that it is different from the original blox name:

Click to Enlarge; Click to Reduce.

Copy Blox Creation Dialog

 

Once you have new Block created, you can edit, or place information in the different scripts by first clicking on a script name, and then add or change the code needed.  

 


Copying Script Statements and Sections:

Script statements can be copied from a block and pasted into a different block by using Control - C, to copy the selected statements, and then using Control - V, after clicking on the block's section editing area when you want to paste the script you just copied.  

 

When any script section that is not already part of a blox where you want that script section to be available, and you have a blox with that script section that already has the script statements you want in a block, the script sections can be copied from where you have it, and then pasted into the block where you would like it to appear.  

 

To do this, click on the script name, and then right-click to select Copy - Ctrl+C:

Click to Enlarge; Click to Reduce.

Script Section Name & Contents Copy

To add the copied script name and it contents, click in the destination block's script list display area.  Right-click to select the Paste - Ctrl+V:

Click to Enlarge; Click to Reduce.

Script Section Name & Contents Paste

After the script name appears in the destination block area, the script code area will display the scripted statement contents of the copied script.

Click to Enlarge; Click to Reduce.

Script Section Name & Contents Paste Results

 


Custom Script Sections:

You can also add new custom scripts which can act as custom functions. Custom Functions are designed to create specialized capabilities that are created by the user.  In these user defined blox the user can create functions that aren't part of the installed functions.  A good reason to create a Custom Function to create a function that is likely to be used by other systems.  When this need occurs, the ability to add a function that is written once, but can be used many times adds capability without the need to recreate that scripting process again.

 


How can you learn more?

Starting from scratch as a beginner, you might find no programming experience daunting.  It will create some confusion, but if you fiddle with what is available already by trying small changes, you'll get a feel for what works, and what else you might need to look up to be successful.  There is also a lot of help to get you started and through the confusion.  Be sure to register with the Trading Blox Builder online Traders' Round-Table Forum.  Forum has a huge amount of information and a lot of blox examples in the Trading Blox Customer Support sections: Trading Blox Support, Blox Marketplace, and Feature Requests groups.

 


Edit Time: 2/5/2018 1:08:54 PM


Topic ID#: 651

 

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