Equilla Quotations and Time Periods
This entry is about quotations that are delivered by the provider and that you need as input values for the calculation of functions, indicators and strategies. It also offers information on working with date and time date. In the end, you can find information and examples on how to find distinct bars in a chart.
For all Equilla functions, you can find additional information in Tradesignal. To call it up, open the source code in the
Equilla Editor. Then right-click on the function in question, e.g.
Accelerator, and choose
Lookup Equilla Function from the context menu. A window opens with information on the function and links to related functions.
Data in Quotation Series
The most important data needed for indicators are the quotations. These are delivered by the data provider and can be displayed in a chart. In addition, you can use external quotations from locally saved files in Tradesignal. From most providers, you will receive the following data:
- Open - Opening price for each trading period
- High - High price for each trading period
- Low - Low price for each trading period
- Close - Closing price for each trading period
- Volume - Trading volume for each trading period
- Open Interest - Open interest in the case of futures
Particularities of Volume Data
Two different definitions of trading volume are in existence, which are often confused.
- The more meaningful definition is that the trading volume is given by the number of traded stocks multiplied with its traded price. This way, the volume represents the amount of capital that was traded in the period.
- Differing from this, sometimes the trading volume is only given as turnover in traded pieces. This means only the number of traded stocks is taken as volume, without information on the traded prices. The problem is that in this case, 100 stocks at 0.20 cents would yield the same volume as 100 stocks traded at $164.40. The number of pieces does not represent the capital used for the trades.
Make sure to ask your data provider which kind of volume data is delivered. Depending on the volume interpretation, indicator data and statistics have to be adapted or put into perspective.
Example: Using Quotations Series without Volume
Meta:
Subchart ( true );
Inputs:
Period( 10, 1 );
Variables:
myOpenValue, myCloseValue, myLowValue, myHighValue,
avgOpen, avgClose, avgLow, avgHigh;
myOpenValue = Open;
myCloseValue = Close;
myLowValue = Low;
myHighValue = High;
avgOpen = Average ( myOpenValue , Period );
avgClose = Average ( myCloseValue, Period );
avgLow = Average ( myLowValue, Period );
avgHigh = Average ( myHighValue, Period );
DrawCandleStick( avgOpen, avgHigh, avgLow, avgClose, Yellow, Red, DarkBlue );
Indicators can be used for more than just the quotations of a single basic symbol in the chart. Many indicators use the quotation series of more than one stock. The same applies to strategies, many of which are based on several symbols or different quotation series. For these calculations, the tools Inline Instruments and Data Inputs are available.
Inline Instruments

Using Inline InstrumentsAn inline instrument is a reference to the stock data which is used directly in the source code. You have to give the symbol and the relevant quotation series. The following example calculates the difference between the quotations of Puma and Adidas Salomon. The result is displayed in a candlestick chart. It does not matter to which chart you apply this indicator - it always uses the given quotations of those two companies. Therefore, inline instruments can be used for calculation with quotations that are not a part of the current chart or portfolio.
Meta:
Subchart( true );
Variables:
openValue, highValue, lowValue, closeValue;
openValue = Open of 'pum ger' - Open of 'ads ger';
highValue = High of 'pum ger' - High of 'ads ger';
lowValue = Low of 'pum ger' - Low of 'ads ger';
closeValue = Close of 'pum ger' - Close of 'ads ger';
DrawCandleStick( openValue, highValue, lowValue, closeValue, White, Red, Black );
Dynamic Inline Instruments
Tradesignal 6 offers you the ability to create inline instruments based on runtime information, e.g. the string inputs of an indicator or strategy may be used instead of a constant string expression.
See the
Equilla Formula Language reference entry
Instruments in Tradesignal for more details on importing symbols.
Input:
Symbol( "" );
Instruments:
mySymbol( Symbol );
DrawLine( mySymbol );
You can also create a list of inline instruments and reference any of the symbols in the list via its index which starts at zero.
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" );
Data Inputs

Using Data Inputs in a ChartWith data inputs, you can access different quotation series or other data in the chart or portfolio. The only condition is that those series are available in the same chart or portfolio during runtime. For example, you can write an indicator displaying the spread between two time series without defining beforehand to which symbols the series belong. You simply start a chart with two symbols and then apply the indicator.
To recreate the indicator from above with data inputs instead of input instruments, create a chart with Puma AG and Adidas Salomon AG. Now enter a new indicator. The quotations are used as data inputs. The first quotation series is referred to as "Data1", the second as "Data2" etc. Since up to twelve symbols can be displayed in a chart, you can enter up to 12 data inputs.
Meta:
Subchart(true);
DrawCandleStick( Open of Data1 - Open of Data2,
High of Data1 - High of Data2,
Low of Data1 - Low of Data2,
Close of Data1 - Close of Data2,
white, red, black);
Date and Time for Quotation Series
The information is delivered with the price data, online or in files. For correct display of quotations, date and time are necessary. This information is also often necessary for other functions, e.g. to recognize day change-overs or certain days of time.
How a Chart is Drawn
The quotations are displayed linearly, from the first period (in the past) to the last. Usually, this is the current day or hour, depending on the time base of the chart. Within an Equilla script, the navigation is done with the consecutive number of the period (not the date or time). Therefore, if you want to use the close price of three days ago in your indicator, you need to write the script so that is goes three periods back in time.
The date cannot be used for this kind of navigation. You cannot retrieve data such as price or volume with a date. However, you can read the date and time of each period for other uses, for example the output of date and time of certain price levels in a chart.
Which Data is offered by Tradesignal?
- Date - The date for the current period as numeric value: 1060609 ( this is the 09.06.2006 )
- Time - The time of the current period as numeric value: 1645 ( this is 16:45 )
- DateTime - A combined expression that is already formatted: 2006/07/05 17:25:00.000 ( this is the 05.07.2006 1725)
Extracting the data with code:
Variables:
myDate;
myDate = Date
Print( myDate );
Variables:
myTime;
myTime= Time;
Print( myTime);
Above, the three basic time series for date and time are given. These data can be read for every period and be used further. In the example above, the date and time were read and printed in the output window. However, it is often necessary to find out single components of the date, for example the day of week, the calendar month or the current year. You may also want to use the given date and time values in another format than the one offered by the system.
Functions for Splitting Date and Time
The following functions are not a complete list of all available functions. Only the most important ones are listed.
For returning date components, you can use the simple functions
Year(date),
Month (date) etc. When entering "now" for the date, the current date is used.
Instead of
day, the function
DayOfMonth can be used.
If IsLastBar Then
Begin
ClearDebug();
Print( "Year=" + CStr( Year( Now ) ) );
Print( "Month=" + CStr(Month( Now ) ) );
Print( "Day=" + CStr( Day( Now ) ) );
Print( "Hour=" + CStr( Hour( Now ) ) );
Print( "Minute=" + CStr( Minute( Now ) ) );
Print( "Second=" + CStr( Second( Now ) ) );
Print( "MilliSecond=" + CStr( MilliSecond( Now ) ) );
End;
To return parts of the
DateTime, the function
DatePart has to be used, defined as
DatePart( DateInterval, DateTime ). For the definition of
DateTime, see above.
The
DateInterval is a numeric constant representing a certain part of the DateTime. It is always constructed with a leading
Interval followed by a date or time expression.
| Interval | Time |
|---|
| Interval_Year | Year |
| Interval_Month | Month of Year (1-12) |
Interval_Day Interval_DayOfMonth | Day of Month (1-31) Day of Month (1-31) |
| Interval_DayOfWeek | Day of Week (0-6) |
| Interval_DayOfYear | Day of Year (1-365) |
| Interval_Hour | Hours |
| Interval_Minute | Minutes |
| Interval_Seconds | Seconds |
Input:
Interval( iYear, iMonth, iDay, iHour, iMinute, iSecond );
Variables:
name, part;
If Interval = iYear Then Begin
name = "Year";
part = Interval_Year;
End Else If Interval = iMonth Then Begin
name = "Month";
part = Interval_Month;
End Else If Interval = iDay Then Begin
name = "Day";
part = Interval_Day;
End Else If Interval = iHour Then Begin
name = "Hour";
part = Interval_Hour;
End Else If Interval = iMinute Then Begin
name = "Minute";
part = Interval_Minute;
End Else If Interval = iSecond Then Begin
name = "Second";
part = Interval_Second;
End;
Print( name + "=" + CStr( DatePart( part, DateTime ) ) );
Functions for Formatting Date and Time Data

Recognize Monday
Display the time in a chartThe basic date and time entries are dry figures. The DateTime component is also not formatted according to European standard. To allow you to generate various date and time formats, complex formatting functions are available. Two important ones are described here.
Meta:
Subchart ( false );
Variables:
myDate, myDay;
myDate = FormatDate ( DateTime, "dd/mm/yyyy");
myDay = DayOfWeek ( Date );
if myDay = 1 Then
DrawText ( High + Range(), "Monday", "Monday," + mydate, 10, blue );
Meta:
Subchart( false) ;
Variables:
myTime, myFormatTime;
myTime = Time;
myFormatTime = FormatTime( DateTime, "hh:mm");
If Time = 0905 Then
DrawText ( High + Range(); "Good morning!", "It is " +myFormatTime,
10, blue);
If Time = 1300 Then
DrawText ( High + Range(); "Lunch time!", "Go and have something
to eat, it is " +myFormatTime, 10, blue);
If Time = 1730 Then
DrawText ( High + Range(); "Bye!", "Call it a day, it is " +myFormatTime,
10, blue);

Displaying continuous bar numbersIn
Equilla Graphs, Outputs and Alerts you can find information on how the navigation in a chart can be controlled by an Equilla script. Reference values are used that can also be interpreted as step sizes. Much as in a game, where a figure makes 6 steps forwards or backwards, the program navigates through the time series.
myPrevDate = Date[ 3 ];
myPrevClose = Close[ 5 ];
From each period in a chart, you have access to all other data and prices in the chart by going back or forward in the data. To do so, some useful functions are available in Tradesignal, which can be used with Equilla.
Meta:
Subchart( false );
Variables:
myBarNum;
myBarNum = CStr( CurrentBar );
DrawText( High + Range(), "Bar numbers", myBarNum, 10, blue);
For many applications it is important to execute a specific action at the very beginning or ending of a chart. For example, variables are often set at the first bar. Two important functions are offered by Tradesignal for this purpose.
- With the first function, you can read out how many bars (periods, candlesticks) are loaded in the chart.
- With the second function, a flag is set which is "true" when the last bar is reached.
Variables:
myEntryCondition, myExitCondition, myBarNums;
If CurrentBar = 1 Then
Begin
myEntryCondition = false;
myExitCondition = false;
End;
If CurrentBar = LastBar Then
Begin
myBarNums = LastBar;
Print ( myBarNums );
End;
If isLastBar = True Then
Begin
myBarNums = LastBar;
Print ( myBarNums );
End;
Last not least it is often important to know the current time base of the indicator. For this, the constant "TimeBase" is available. With it you get the number of seconds spanned by each bar. With some mathematics, we can quickly find out if the indicator is in a day chart or one with a five minute span.
Variables:
outputString("");
If CurrentBar = 1 Then
Begin
if TimeBase = 86400 Then
outputString="d";
if TimeBase = 3600 Then
outputString="1h";
if TimeBase = 300 Then
outputString="5m";
if TimeBase = 60 Then
outputString="1m";
End;
If isLastBar Then
Print ( outputString );