Script Object Functions & Properties:

All functions and properties require the script-object name as a prefix word connected by a period '.' to a function or property keyword: script. plus the FunctionName or propertyName.

 

'  This Script built-in Function will execute

'  the text-named script section shown next:
script.Execute("AnyNameScript")

 

Similar to: Script.Execute() is the function: Script.InstrumentLoop().  This additional function will run a custom script that will loop each enabled instrument in the portfolio.  Click on this InstrumentLoop link for an example of how it can be used.  

 

Functions Name:

Descriptions:

Execute()

Use this function to Execute a custom script name that is available to the system.

Exists()

This function will return the existence of a custom script.  This function can be Executed any block to discover the existence of the named custom script exists is included or not found in the system.  

 

The ability to know a script exists prior to making an script.Execute( "Script-Name") call provides an opportunity to know if a named custom script is available before an error happens.  

 

This next Code-Example provides a process that can be used to know what scripts are in the system and how to effectively access them quicker.

'   ---------------------------------------

'   script.Exist & script.GetReference Example

'   ---------------------------------------
'  When not certain, test to ensure Custom
'  Script “MyCustomScript” is accessible.
If script.Exists( MyCustomScript ) THEN
 
  '  Get the Custom Scripts Numeric ID
  '  for Faster Custom-Script access.
  BPV_ID = script.GetReference( MyCustomScript )
 
  '  Script is Available, call the script
  '  script using Referemce ID-Number
  script.Execute( BPV_ID )    
ELSE
  '  Script is NOT Available, do something else
  PRINT Bad New !!!”
ENDIF

'  ---------------------------------------

Custom-Script sections now have the ability to GetReference a ID for each custom script name in a system.  Read the GetReference function for more information about its purpose and use.

GetReference()

The GetReference function returns an integer reference ID value that makes access to a custom script more efficient.  Once a custom script reference is found, the ID-number can then be used to access that script faster and efficiently than will happen when the name of the custom script section is used.  

 

Review the Example Code in the Exists function description.

 

In the Before Test script, it is possible to get the Custom-Script's ID for each of the Custom-Script section that can be saved in a BPV-Integer variables so they are available to access each Custom-Script during a test.    In use, it is faster to use Reference-ID numbers to access a Custom-Script ID number than to use the Custom-Script's "text-name" .

GetSeriesValue()

Used to access a value from a passed in series.  Access is as defined for the series so that auto indexed series use an offset base, and non auto indexed series are manual direct index access.

InstrumentLoop()

This function is similar to Script.Execute function.  This function when run in a custom script will access each enabled instrument in the portfolio.  

 

To enable or disable an instrument, use the instrument.DisableTrading function to change the instrument's inPortfolio state from TRUE to FALSE.  

 

Typically this inPortfolio state is executed from SetParameters script section.  Instrument data that is disabled will not be loaded into memory when the Before Test script section runs.

OrderLoop()

Loops over all open orders in the system and calls the custom script.

SetReturnValue()

Used to set the return value to a number or string.

SetReturnValueList()

Used to set a list of number return values.

 

Functions used in the custom function:

'  Used to set the return value to a number or string
script.SetReturnValue( value or string value, or value and string value )

 
'  Used to set a list of number return values.
script.SetReturnValueList( value1, value2, value3... )
 
'  Used to access a value from a passed in series. Access is as defined for
'  the series so that auto indexed series are offset based, and non auto
'  indexed series are manual direct index based.
script.GetSeriesValue( seriesParameterIndex, offsetIndex )

 

 
  '  These are Subrountine Processes for Setting the User Function's RETURN value
  Script.SetStringReturnValue( STRING value ) '  Use FOR a STRING RETURN

 


Edit Time: 10/29/2020 10:52:35 AM


Topic ID#: 517

 

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