Data-Types: |
Description: |
---|---|
Instrument & BPV |
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. |
Notes:
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:
Script Instrument Access |
|
---|---|
Automatic Access: |
Manual Access: |
When access to instrument information isn't automatic, a script section can loaded an instrument using the BPV Instrument Variable-Type with the LoadSymbol function (see linked topic).
This next example shows how all of the instruments in the portfolio can be loaded and accessed:
Example: |
---|
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Returns: |
Mkt.Symbol CL2 |
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:
Example: |
---|
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Returns: |
Corn Market Loaded Soybean Market Loaded Wheat Market Loaded |
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:
Example: |
---|
' Script line using BPV Instrument Corn placed in each of ' Blox script sections so that each could report what it ' found accessible. |
Returns: |
' Details shown are text copies of some of the Before Test C2 2007-12-27 508.250000000 Update Indicators C2 2007-12-27 508.250000000 Before Trading Day C2 2007-12-27 508.250000000 Before Instrument Day C2 2007-12-27 508.250000000 Update Indicators C2 2007-12-28 505.500000000 After Instrument Day C2 2007-12-28 505.500000000 After Trading Day C2 2007-12-28 505.500000000 Before Trading Day C2 2007-12-28 505.500000000 Update Indicators C2 2007-12-31 509.000000000 After Instrument Day C2 2007-12-31 509.000000000 After Trading Day C2 2007-12-31 509.000000000 After Test C2 2007-12-31 509.000000000 After Simulation C2 2007-12-31 509.000000000 |
Check the script section name topic for information that might not be presented here.
Links: |
---|
See Also: |
Edit Time: 9/12/2020 10:28:44 AM |
Topic ID#: 386 |