Equilla Operators
An important part of the scripts is the calculation of values. Often only basic arithmetic is necessary for these calculations, but sometimes the tasks are more complex. Equilla places many operators for calculating and comparing values at your disposal.
Calculations
Basic Arithmetics
For calculating values, the four basic arithmetic operations are available. These are used most often.
Variables:
myFirstVar, mySecondVar, myThirdVar;
myFirstVar = mySecondVar + myThirdVar;
myFirstVar = mySecondVar - myThirdVar;
myFirstVar = mySecondVar * myThirdVar;
myFirstVar = mySecondVar / myThirdVar;
If myThirdVar <> 0 Then
myFirstVar = mySecondVar / myThirdVar
Else
myFirstVar = myFirstVar [ 1 ];
myFirstVar = Divide( mySecondVar , myThirdVar );
Mathematical Functions for Complex Calculations
With some effort, every calculation can be performed. However, you can reduce the programming load by using functions already provided for special tasks. You can find a list of all functions by clicking the
Function button in the toolbox. To see the code, double-click the function or select
Edit from the context menu.
In the following, excerpts of some important functions and their use are given.
Meta:
Subchart( false );
Inputs:
Period( 10 );
Variables:
myFirstVar, mySecondVar, myThirdVar;
myFirstVar = HHV( Close, Period );
mySecondVar = High - Low;
myFirstVar = HHV( mySecondVar, Period );
myFirstVar = LLV( Close, Period );
mySecondVar = High - Low;
myFirstVar = LLV( mySecondVar, Period );
myFirstVar = MaxItems( Open, Close ) - MinItems( Open, Close );
If isLastBar Then
Begin
myFirstVar = Frac( 5.5 );
Print( myFirstVar );
End;
If isLastBar Then
Begin
myFirstVar = Floor( 5.5 );
Print( myFirstVar );
End;
If isLastBar Then
Begin
myFirstVar = Ceiling( 5.5 );
Print( myFirstVar );
End;
If isLastBar Then
Begin
myFirstVar = Cos( 5.5 );
Print( myFirstVar );
End;
Comparisons
When calculating an indicator, it is often necessary to compare values and then execute certain functions. For value comparison, several operators are available.
Simple comparisons between two values
Meta:
Subchart( false );
Variables:
myFirstVar, mySecondVar, myThirdVar;
If isLastBar Then
Begin
If myFirstVar = mySecondVar Then
Print( "Hello World" );
End;
If isLastBar Then
Begin
If myFirstVar <> mySecondVar Then
Print( "Hello World" );
End;
If isLastBar Then
Begin
If myFirstVar >= mySecondVar Then
Print( "Hello World" );
End;
If isLastBar Then
Begin
If myFirstVar <= mySecondVar Then
Print( "Hello World" );
End;
Comparisons between several values through combination
Meta:
Subchart( false );
Variables:
myFirstVar, mySecondVar, myThirdVar;
If isLastBar Then
Begin
If ( myFirstVar = mySecondVar ) AND ( myFirstVar = myThirdVar ) Then
Print( "Hello World" );
End;
If isLastBar Then
Begin
If ( myFirstVar = mySecondVar ) OR ( myFirstVar = myThirdVar ) Then
Print( "Hello World" );
End;
If isLastBar Then
Begin
If ( myFirstVar = mySecondVar ) XOR ( myFirstVar = myThirdVar ) Then
Print( "Hello World" );
End;
Finding crossing time series
One of the most important problems in indicators and strategies is the search for intersections between prices and averages, indicators and alert lines etc. Tradesignal offers several functions for this task.
Meta:
Subchart( false );
Inputs:
PeriodFast( 10 , 1 ),
PeriodSlow( 20 , 1 );
Variables:
fastAvg, slowAvg;
fastAvg = Average( Close, PeriodFast );
slowAvg = Average( Close, PeriodSlow );
If isLastbar then
Begin
If fastAvg Crosses Over slowAvg Then
Alert( "Average moves upwards" );
If fastAvg Crosses Under slowAvg Then
Alert( "Average moves downwards" );
End;