Data instrument access to its properties and functions is automatic when the instrument has context, and when the symbol is active in a script where instruments have context. Context means the information is automatically made available when that script section is executing and the portfolio looping brings that instrument into the script.
When other script sections are executing, Trading Blox doesn't loop instruments, but instead will on execute scripts without instrument context once for each bar being tested. To access an instrument the script will need to bring the instrument into context in order to gain access to its properties and functions. To bring an instrument into context, use a BPV Type Instrument variable as the structure where the instruments data can be copied so it can be accessed.
This table is a current list of the script section that automatically bring instruments into context automatically, and the scripts sections where scripting code will be required to gain access to an instrument:
When access to instrument information isn't automatic it can be loaded into the BPV Instrument Variable Type using the LoadSymbol function. This next example shows how all of the instruments in the portfolio can be loaded and accessed:
In the above example a generic name of 'Mkt' was assigned to the BPV instrument. When an instrument access needs to be available through out a simulation, a unique name can be given to a BPV instrument so it canceled using that unique name and thus be available without having to bring it into context with a loading script. Consider this simple Grain market example:
In the above example each of the grain markets can be called in any of the script sections without having to load them where they are not normally in the context of that script. Calling them in any of the scripts would look something like this: