Support

Equilla Formula Language

Instruments

When writing an indicator or a strategy, Equilla provides multiple ways to reference price data from different data inputs. Beside the standard and inline instruments, you can import instruments dynamically based on runtime information.

Syntax

Instruments: variable( ImportDirective );

Inputs


:
variable
: A user defined variable that can be used to access the imported data in your script.
ImportDirective
: Specifies what kind of instrument data should be imported. For details on the supported import directives, please check the remarks section.

Remarks

Equilla support a set of five different ways to import instruments dynamically.

Import Directives

ImportDirectiveDescription
String expressionImports a single instrument.
ExpiredListImports a list of expired future contract instruments.
ForwardCurveImports a forward curve instrument.
ListImports a list of instruments based on the specified symbol list.
SeasonalListImports a list of future instruments and performs a seasonal transformation.

Importing a single instrument

If none of the other import directives is specified for an instrument import, equilla assumes that a single instrument should be imported. The given expression will be interpreted as a string and the system will try to resolve the instrument using that information.

The format of that string is the same as for inline instruments as described in Data Inputs and Inline Instruments.

"SymbolName [Period [FID [Unit [Currency]]]]"

Referencing imported instruments

Once an instrument or list of instruments has been imported, it can be referenced in the script, using the variable specified in the declaration.

variable[(Index)]

Inputs

variableThe name of the variable as specified in the instruments declaration block.
Index(Optional) The zero based index of the instrument you want to access. If omitted the first instrument will be used.

To determine the number of instruments that have been imported for a specific declaration, pass the variable to the Len function.

Restrictions on Instrument declarations

The parameters passed to an instrument import can be build dynamically at runtime, using standard Equilla code. The following restrictions apply to the code used in instrument declarations:

Note: All instruments that have been imported using this method can be used the same way standard or inline instruments are used. To do that simply use the attached variable name instead of the DataID (Data1, Data2, ...) or inline instrument id (i. e. '.DJI').

Note: All instruments imported using this functionality will be treated as inline instruments. This is important when trying to determine how output bars will be generated. See the documenation of Data Inputs and Inline Instruments for details.

Examples

Import a single instrument and reference it in the script
Input: Symbol( "" ); Instruments: mySymbol( Symbol ); DrawLine( mySymbol );
Import a list of instruments and calculate the average price
Input: ListSymbol( "" ); Instruments: myInstruments( List( ListSymbol ) ); Variables: prices( 0 ), i( 0 ); prices = 0; For i = 0 to Len( myInstruments ) - 1 Begin prices = prices + Close of myInstruments( i ); End; If Len( myInstruments ) != 0 Then DrawLine( prices / Len( myInstruments ), "Average" );
Trading a list of dynamically imported inline instruments
Input: SymbolList( "" ); Instruments: myList( List( SymbolList ) ); Variables: i( 0 ); For i = 0 To Len( myList ) - 1 Begin Buy Trading myList( i ); End;