Equilla Conditions
One of the most important aspects of programming indicators, strategies or other routines is the reaction to certain events, like calculation results or user inputs. Without the control, activation or deactivation of program parts depending on those events, no complex programming would be possible.
For all Equilla conditions, you can find additional information in TradeSignal. To display it, open the source code in the
Equilla Editor. Then right-click on the operator in question, e.g.
Else, and choose
Lookup Equilla Function from the context menu. A window opens with information on the operators and links to related functions.
Simple Condition (If ... Then)
You can use the key words
If...Then to encapsulate one or more conditions. Depending on the results, different actions are performed. The conditions can be combined by using the three operators And, Or and Xor (see the chapter
Equilla Operators).
Meta:
Subchart( false );
Inputs:
commodities( Silver, Gold );
If Commodities = 0 Then
Print( "Silver price rises." )
Else
Print( "Gold price rises." );
Conditions with Branching (If...Then...Else)
By entering an alternative command, your script can react to met and not met conditions likewise. When testing several cases at once, it is sensible to process them within the same context.
Meta:
Subchart( false );
Inputs:
commodities( Silver, Gold, Platin );
If Commodities = 0 Then
Print( "Silver price rises." )
Else
Print( "Gold price rises." );
If Commodities = 0 Then
Print( "Silver price rises." )
Else If Commodities = 1 Then
Print( "Gold price rises." )
Else
Print( "Platin price rises." );
Please note that the line before the Else statement must not end with a semi-colon.
Nested Conditions
You can put several statements into a block and nest queries. The following example shows how to write begin-end blocks and nested conditions.
If cucumber = green Then
Begin
If ( cucumber = fresh ) Then
Begin
"Cut in slices";
"Add tomato slices";
"Add dressing";
If Today = Friday Then
"Put lots of garlic in the dressing"
Else
"Skip garlic";
End
Else
"Drive to another store";
End;