FIGURE 1: USER INTERFACE IN TRADESIGNAL.
Tradesignal offers near-unlimited opportunities to generate indicators, chart patterns and entire trading systems with the formula-based language Equilla.
FUNCTIONS FORM THE BASIS FOR INDICATORS.
It is very simple to look “inside” the Equilla code. Right-click the trading system or the indicator in the chart. This shows you that every indicator, every chart pattern and all trading systems make use of functions. A function is a subordinate programme part into which calculations and programme instructions that need to be reused more often are outsourced.
A SIMPLE EXAMPLE:
Instead of programming the complete calculation of the standard deviation every time, it is “packed” in a function and applied with a name. By calling the name, the programmer will have the desired result available at any time without detours and will be able to reuse it within the source code. To calculate a moving average (MA), the function “AverageFC” is already predefined in Tradesignal.
Price( NumericSeries ),
Period( NumericSimple );
If Period > 0 Then
AverageFC = SummationFC( Price, Period ) / Period
AverageFC = 0;
FIGURE 2: FUNCTION “AVERAGEFC”.
The function shown above calculates a simple moving average. Functions are the foundation for indicators, from which trading strategies can be created.
HOW IS THE SOURCE CODE STRUCTURED IN EQUILLA?
The results of the functions just described form the basis for the actual indicator. As an example, we show the “simple moving average” (SMA) in figure 3, which permits the MA on a price series to be displayed. The associated code is used to explain the basic programme structure and syntax of Equilla.
Categories( "Trend Follower" ),
Synopsis( "This is the finished indicator, which calculates the Simple Moving Average. It is based on the functions AverageFC and SummationFC." ),
ShortCode( "SMA" ),
SubChart( False );
Price( Close ),
Period( 10, 1 );
DrawLine( AverageFC( Price, Period ), "SMA");
FIGURE 3: EQUILLA CODE FOR INDICATOR „SIMPLE MOVING AVERAGE“.
The code contains all parameters that can later be changed or optimised by the user in the input area. Then there is the command for the graphical illustration of the moving average in the chart (DrawLine).
Let us start with the header part of the code, which is always recognised by the term „Meta:“. Here, global (meta) information for the indicator is specified. In this specific case, the programmer has defined the following:
- Synopsis: A description of the indicator
- ShortCode: A short code with which the indicator can be quickly loaded into the chart via a keystroke
- SubChart: The instruction that the indicator is not to be displayed in a subchart (false), but the main chart
Next comes the input area. Here, the user-specific parameters called “inputs” are described, which can later comfortably be modified via the input mask of the software or optimised via an optimisation tool. In the specific case, the input “Price ( Close )”specifies that the SMA is to be calculated at the closing price.
The input “Period ( 200, 1 )” is used to enter the period number. The standard setting here is specified with the value 200. Then number 1 after the comma means that 1 is the smallest possible input value.
Another important task is met by variables, which serve as a kind of “container” within the source code. They save results and make them accessible for further processing and later use. This indicator code contains no such variables. In the second part of our Equilla series, we will deal in detail with their description and use in the scope of a trading system.
Let us now come to the next part of the programme. This is all about calculation. In this specific example, the MA must be calculated for each period. This is done by the function “AverageFC” that has already been mentioned. If the calculated indicator value is to be output in a visual form, only the right closing command is needed after this. With the expression “DrawLine”, the software is instructed to draw a line.
The attentive reader will have noticed here that the use of commas and semicolons plays an important role when programming. Generally, a comma is used in each case to specify inputs and variables. Only the end of the last instruction needs to use a semicolon so that the code can later be translated (“compiled”) properly. In Tradesignal, compiling can be started by pushing F7. The software does the rest.
BY THE WAY:
In the Equilla editor named above, parts of the source code are highlighted in colour according to their functions (e.g. “DrawLine”). This makes it easier to read the code. Additionally, the visual structure helps in finding errors that – if present – will be displayed automatically in the editor with a precise line reference.
Particularly for new users, it is helpful to right-click the blue terms for detailed information and example applications. While writing code, small help windows also provide valuable advice on the proper use of a term.