Trading Objects Reference

Top  Previous  Next

Trading Objects represent real-world objects used in trading, the instrument object represents a tradeable market, the broker represents the broker who takes your orders, etc.

 

Blox Basic scripts use the Trading Objects to access information and to affect the trading simulation. The Trading Objects used in Trading Blox Builder are:


 

 

instrument

 

represents a given market or tradeable instrument to access pricing, position information, and to filter trading

broker

 

represents a broker and is used to enter orders with their stops

system

 

represents the system itself and is used to access system-level information such as the total equity

order

 

contains information about the order used in the Can Fill Order script

test

 

represents the test and is used to obtain test-level information like the start and end dates

block

 

represents the current Trading Block and is generally only used for debugging purposes

fileManager

 

used to read and write files

 

The trading objects are used in scripts, but not all objects are available in all scripts. For example, the Before All Tests script is run once at the beginning of a multi-parameter test and it does not define the "instrument" object. Only scripts which are run for individual instruments in the system's portfolio define the "instrument" object.

 

If you use an object in a script for which it has not been defined you will get an error like the following when you run the script:

 

"I'm sorry I could not understand the 'Before All Tests' script at line 24 because an attempt has been made to access the Instrument object out of context."

 

Indexing

If a property is "indexable" it will be listed in the properties list with brackets following the name like "close[ ]", the values for that property are available for your use for dates in the past or for more than one item in a list of items. The meaning of a bracket depends on the type of property.  To access these values, use a number or numeric variable in brackets as follows:

 

instrument.close[ 5 ]           ' the close five days ago.

 

test.totalEquity[ lookback ]    ' the total equity for all

                               ' systems 'lookback' days ago

                               ' using the value of the lookback

                               ' variable

 

instrument.unitEntryPrice[ 1 ]  ' the exit price for unit one

 

instrument.tradeProfit[ 1 ]     ' the profit of the last trade

 

If you don't use brackets, the most recent value is assumed. So

 

instrument.close

 

is the same as

 

instrument.close[0]

 

Case Sensitivity and Coding Style Conventions

Blox Basic is case-insensitive so it will accept any case for object Properties and Functions. However, in this manual we use the convention of using lower case for the start of an object's Properties, and uppercase for the start an object's functions.

 

The following sections illustrate the specific access mechanisms called Properties and behavior affecting mechanisms called Functions for each Trading Object.