# Keywords

### AddOutput() <a href="#addoutput" id="addoutput"></a>

### AddLine() <a href="#addline" id="addline"></a>

#### Description <a href="#description" id="description"></a>

The add method allows you to add plots or line objects to the chart. When a new plot object is added using Add(), this automatically creates a data series of the type DataSeries, which is attached to this object. The value collection allows you to reference and access this data series. Add() can be used with the OnInit() and the OnCalculate() methods.

#### Parameter <a href="#parameter" id="parameter"></a>

plot – a *OutputDescriptor* object line – a *LevelLine* object

#### Usage <a href="#usage" id="usage"></a>

```csharp
AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
Add(LevelLine line)
```

#### Example <a href="#example" id="example"></a>

```csharp
#region Usings
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Xml;
using System.Xml.Serialization;
using AgenaTrader.API;
using AgenaTrader.Custom;
using AgenaTrader.Plugins;
using AgenaTrader.Helper;
#endregion
namespace AgenaTrader.UserCode
{
  [Description("Enter the description for the new custom indicator here")]
  public class MyIndicator : UserIndicator
  {
    protected override void OnInit()
    {
    // Two blue lines will be placed into the chart, one at 70 and the other at 30
    AddLine(new LevelLine(Color.Blue, 70, "UpperLine"));
    AddLine(new LevelLine(Color.Blue, 30, "LowerLine"));

    // Add 2 plots
    AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Red), "FastSMA"));
    AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Blue), "SlowSMA"));
    }

    protected override void OnCalculate()
    {
    //The set method is assigned to the value of the current bar
    FastSMA.Set( SMA(8)[0] ); // is identical with Outputs[0].Set( SMA(8)[0] );
    SlowSMA.Set( SMA(50)[0] ); // is identical with Outputs[1].Set( SMA(50)[0] );
    }

    // Two data series are made available here
    // These are not necessary for the display of the indicator // With the help of these series, one indicator can access the other
    // For example: double d = MyIndicator.FastSMA[0] - MyIndicator.SlowSMA[0];
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries FastSMA
    {
      get { return Outputs[0]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries SlowSMA
    {
      get { return Outputs[1]; }
    }
  }
}
```

### AllowRemovalOfChartDrawings <a href="#allowremovalofchartdrawings" id="allowremovalofchartdrawings"></a>

#### Description <a href="#description_1" id="description_1"></a>

"AllowRemovalOfChartDrawings" is a property of indicators that can be set under [*OnInit()*](#oninit).

**AllowRemovalOfChartDrawings = true**

Drawing objects that are drawn by an indicator or a strategy can be manually removed from the chart.

**AllowRemovalOfChartDrawings = false (default)**

Drawing objects that have been created by a strategy or indicator CANNOT be manually removed from the chart. They are removed once the indicator or strategy is removed.

This property can be queried and will return "true" or "false".

#### Usage <a href="#usage_1" id="usage_1"></a>

```csharp
AllowRemovalOfChartDrawings
```

#### Example <a href="#example_1" id="example_1"></a>

```csharp
protected override void OnInit()
{
AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
//Drawing objects can be manually removed from the chart
AllowRemovalOfChartDrawings = true;
}
```

### Attribute <a href="#attribute" id="attribute"></a>

Attribute is a component of the C# language. Within AgenaScript, indicators, and strategies, you can use these attributes in the same manner as you would in C#. Information regarding the usage of attributes can be found here:

<https://learn.microsoft.com/de-de/dotnet/csharp/advanced-topics/reflection-and-attributes/>

The most commonly used attributes in AgenaScript are:

* [*Browsable*](#browsable)
* [*Category*](#category)
* [*ConditionalValue*](#conditionalvalue)
* [*Description*](#description_2)
* [*DisplayName*](#displayname)
* [*TimeFrameRequirements*](#timeframerequirements)
* [*XmlIgnore*](#xmlignore)

### Browsable <a href="#browsable" id="browsable"></a>

Browsable is an [Attribute](#attribute) within AgenaScript.

AgenaScript uses public variables for entering parameters for indicators (such as periods for the SMA) and for outputting events and calculations within indicators (for example, data series). Variables used for entering parameters must be displayed in the properties dialog. Data series are exempt from this. Public variables with the browsable attribute set to false are not displayed within the properties dialog.

By default, browsable is set to true. Therefore, within a variable containing an entry parameter, the attribute does not need to be specified.

**Example for a parameter:**

The parameter should be displayed and queried in the properties window. Therefore browsable should be set to true.

```csharp
[Description("Numbers of bars used for calculations")]
[Category("InputParameter")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
```

**Example for a data series:**

```csharp
[Browsable(false)]
[DisplayName("Lower band")]
[XmlIgnore]
public DataSeries Lower
{
get { return Outputs[0]; }
}
```

### Category <a href="#category" id="category"></a>

Category is an [Attribute](#attribute) in AgenaScript and can be used on properties and classes.

The category attribute on properties defines under which category in the properties dialog the parameter is shown. If this attribute is missing, the parameters category is accepted as the standard.

The following example shows how to create the new category "My InputParameter" in the properties dialog:

```csharp
[Category("My InputParameter")]
[DisplayName("Period number")]
public double _period
{
get { return _period; }
set { _period = value; }
}
```

![Category](https://agenatrader.github.io/AgenaScript-documentation/media/image11.png)

If you use the category [Attribute](#attribute) on classes you are able to create subcategories for your scripts and group them all in one category. This is pretty useful if you are creating a package and you want to group a few indicators in a group with one name.

The following example shows how to create a subfolder "My Package":

```csharp
namespace AgenaTrader.UserCode
{
    [Description("Description what this indicator doing.")]
    [Category("My Package")]
    public class MyHolyGrail_Indicator : UserIndicator
    {
      /* your code here */
    }
}
```

### ConditionalValue <a href="#conditionalvalue" id="conditionalvalue"></a>

Conditional value is an [Attribute](#attribute) in AgenaScript.

Normally, when making comparisons within the ConditionEscort, the data series generated by indicators are used. One such example would be checking whether a moving average lies above or below a specific price value. An indicator can also yield values that are not contained within data series, such as values of the type int, double, char, Boolean, string, etc. To use these values within the scanner or ConditionEscort, they have to be labeled with the conditional value attribute.

```csharp
[Browsable(false)]
[XmlIgnore]
[ConditionalValue]
public int PublicVariable
{
get
{
Update();
return _internVariable;
}
}
```

### Description <a href="#description_2" id="description_2"></a>

Description is an [Attribute](#attribute) in AgenaScript.

The description attribute is used in AgenaScript for classes and public variables. As an attribute of the class, the text is a description of the function of the entire indicator.

```csharp
[Description("Displays the tick count of a bar.")]
public class TickCounter : UserIndicator
{
//As an attribute of a public variable, the text is a description of the function of the parameter.
[Description("Number of standard deviations")]
[DisplayName("# of std. dev.")]
public double NumStdDev
{
get { return numStdDev; }
set { numStdDev = Math.Max(0, value); }
}
}
```

The descriptions are displayed in the relevant properties dialog.

### DisplayName <a href="#displayname" id="displayname"></a>

Display name is an [Attribute](#attribute) in AgenaScript.

The display name attribute defines the text shown in the properties dialog for the parameter.

If this attribute is not specified, the name of the public variable is used.

```csharp
[Description("Number of standard deviations")]
[DisplayName("# of std. dev.")]
public double NumStdDev
{
get { return numStdDev; }
set { numStdDev = Math.Max(0, value); }
}
```

### TimeFrameRequirements <a href="#timeframerequirements" id="timeframerequirements"></a>

Timeframe requirements is an [Attribute](#attribute) in AgenaScripts.

If you want a script to use data from various timeframes, the class requires the attribute „TimeFrameRequirements". You can specify multiple timeframes here:

```csharp
[TimeFrameRequirements("1 day")]
[TimeFrameRequirements("15 minutes", "1 day", "1 week")]
```

The amount of data provided for the other timeframes will always be the same as the number of actual candles loaded into the chart. If there are 500 candles for a 5-minute chart, then 500 candles of another timeframe will also be loaded. In the first example above, 500 daily candles will be loaded. In the second example, 500 15-minute candles, 500 daily candles and 500 weekly candles will be loaded. The amount of data can become rather large very quickly, thus you should take precautions when using this attribute.

See [*MultiBars*.](/handling-bars-and-instruments/multibars.md#multibars)

**Important:**

If a class uses a different indicator that requires one or more secondary timeframes, then the "TimeFrameRequirements" attribute must be set for the class retrieving the data. An example for this can be seen here: *GetDayBar*.

### XMLIgnore <a href="#xmlignore" id="xmlignore"></a>

XML ignore is an [Attribute](#attribute) in AgenaScript.

AgenaTrader saves all parameter settings for the indicators in a template. The template files are saved in an XML format. In order to avoid a parameter being saved as part of the template, the attribute XML ignore can be set.

To save parameters in an XML file, the values must be serialized. Under most circumstances, AgenaTrader performs this automatically. Self-defined data types cannot be serialized automatically, so in this case the programmer is responsible for the correct serialization. In the following example, the color and font are used as parameters of an indicator. AgenaTrader has two methods for serializing color and font information (TextColorSerialize and TextFontSerialize). Both parameters – TextColor and TextFont – thus need to be marked with the XML ignore parameter.

```csharp
private Color _textColor = Color.Blue;
private Font _textFont = new Font("Arial", 12, FontStyle.Bold);
[XmlIgnore]
[Description("Textcolor")]
public Color TextColor
{
get { return _textColor; }
set { _textColor = value; }
}
[Browsable(false)]
public string TextColorSerialize
{
get { return SerializableColor.ToString(_textColor); }
set { _textColor = SerializableColor.FromString(value); }
}
[XmlIgnore()]
[Description("TextFont")]
public Font TextFont
{
get { return _textFont; }
set { _textFont = value; }
}
[Browsable(false)]
public string TextFontSerialize
{
get { return SerializableFont.ToString(_textFont); }
set { _textFont = SerializableFont.FromString(value); }
}
```

### CalculateOnClosedBar <a href="#calculateonclosedbar" id="calculateonclosedbar"></a>

#### Description <a href="#description_3" id="description_3"></a>

The property "CalculateOnClosedBar" determines the events for which AgenaTrader can call up the OnCalculate() method.

```csharp
CalculateOnClosedBar = true
```

**OnCalculate()** is called up when a bar is closed and the next incoming tick creates a new bar.

```csharp
CalculateOnClosedBar = false
```

OnCalculate() is called up for each new incoming tick. If you are running AgenaTrader on older hardware, this may cause performance issues with instruments that are highly liquid. The property can be queried in the script and will return a value of the type Boolean (true or false). CalculateOnClosedBar can be used within OnInit() and also within OnCalculate(). OnCalculate() is only called up for the closing price of each bar with historical data, even if CalculateOnClosedBar is set to false. When an indicator is called up by another indicator, the CalculateOnClosedBar property of the retrieved indicator overwrites the indicator performing the retrieving.

The default value of this property is true so in default setup your script does not use tick data.

#### Usage <a href="#usage_2" id="usage_2"></a>

CalculateOnClosedBar

#### More Information <a href="#more-information" id="more-information"></a>

See [*Bars*.](/handling-bars-and-instruments/bars.md)

#### Example <a href="#example_2" id="example_2"></a>

```csharp
protected override void OnInit()
{
//Indicator calculation should only occur when a bar has closed/finished
CalculateOnClosedBar = true;
}
```

### Chart <a href="#chart" id="chart"></a>

Chart control is an object that provides reading access of various properties for the chart.

The important properties are:

* ChartFontColor, BackColor
* UpColor, DownColor
* Font
* BarMarginLeft, BarMarginRight
* BarSpace, BarWidth
* BarsPainted
* FirstBarPainted, LastBarPainted
* BarsVisible
* FirstBarVisible, LastBarVisible
* GetXByBarIdx, GetYByValue

An example can be seen here: [*PlotMethod*](#plotmethod).

**BarsPainted und BarsVisible:**

BarsPainted contains the number of bars that a chart *could* display from the left to right border with the current width and distance of the candles. BarsVisible contains the number of bars actually visible.

**FirstBarPainted und FirstBarVisible:**

FirstBarPainted contains the number of the bar that *would* be displayed on the left border of the chart.

FirstBarVisible contains the number of the bar that is actually shown as the first bar on the left side of the chart area.

Example: the chart has been moved so that the first bar of the chart is now in the middle of the chart.

FirstBarPainted would be negative.

FirstBarVisible would be 0.

**LastBarPainted und LastBarVisible:**

LastBarPainted contains the number of the bar that *would* be displayed on the right border of the chart.

LastBarVisible contains the number of the bar that is actually displayed on the right side of the chart.

Example: the chart has been moved so that the last bar of the chart is displayed in the middle section.

LastBarPainted would be larger than Bars.Count.

LastBarVisible would be Bars.Count -1.

### ClearTraceWindow() <a href="#cleartracewindow" id="cleartracewindow"></a>

#### Description <a href="#description_4" id="description_4"></a>

The ClearTraceWindow() method empties the output window. The method can be used within OnInit() as well as within OnCalculate(). The output window contains all outputs that have been created with the [*Print()*](#print) command. Using the output window is a great method for code debugging.

#### Usage <a href="#usage_3" id="usage_3"></a>

```csharp
ClearTraceWindow()
```

#### Parameter <a href="#parameter_1" id="parameter_1"></a>

none

#### Return Value <a href="#return-value" id="return-value"></a>

none

#### Example <a href="#example_3" id="example_3"></a>

```csharp
protected override void OnInit()
{
// Delete the content of the output window
ClearTraceWindow();
}
```

### Colors <a href="#colors" id="colors"></a>

AgenaScript provides you with the following commands for defining colors and making color changes to the chart:

[*BarColor*](#barcolor) Color of a bar

[*BackColor*](#backcolor) Background color of the chart

[*BackColorAll*](#backcolorall) Background color of the chart and all panels

Chart.UpColor Color of up ticks (up bars) Chart.DownColor Color of down ticks (down bars)

For each bar, its colors are saved in the following data series. If these data series are written in, the color of the referenced bar will change.

[*BarColorSeries*](#barcolorseries)

[*CandleOutlineColorSeries*](#candleoutlinecolorseries)

[*BackColorSeries*](#backcolorseries)

[*BackColorAllSeries*](#backcolorallseries)

### BackColor <a href="#backcolor" id="backcolor"></a>

#### Description <a href="#description_5" id="description_5"></a>

Back color changes the background color of a bar or gives the current background color of a bar when queried.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_2" id="parameter_2"></a>

A color object of the type "public struct color"

#### Usage <a href="#usage_4" id="usage_4"></a>

BackColor

#### Example <a href="#example_4" id="example_4"></a>

```csharp
// Every Monday, change the bar background color to blue
if (Time[0].DayOfWeek == DayOfWeek.Monday)
BackColor = Color.Blue;
```

![BackColor](https://agenatrader.github.io/AgenaScript-documentation/media/image16.png)

```csharp
// Changing the bar background color depending on a smoothing average
// Market price above the SMA(14) to green
// Market price below the SMA(14) to maroon
BackColor = SMA(14)[0] >= Close[0] ? Color.Maroon : Color.LimeGreen;
```

![BackColor](https://agenatrader.github.io/AgenaScript-documentation/media/image17.png)

### BackColorAll <a href="#backcolorall" id="backcolorall"></a>

#### Description <a href="#description_6" id="description_6"></a>

Back color all changes the background color of a bar within the chart window and in all subcharts.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_3" id="parameter_3"></a>

A color object of the type "public struct color"

#### Usage <a href="#usage_5" id="usage_5"></a>

BackColorAll

#### Example <a href="#example_5" id="example_5"></a>

```csharp
// Every Monday, change the bar background color to blue
if (Time[0].DayOfWeek == DayOfWeek.Monday)
BackColorAll = Color.Blue;
```

![BackColorAll](https://agenatrader.github.io/AgenaScript-documentation/media/image18.png)

### BackColorAllSeries <a href="#backcolorallseries" id="backcolorallseries"></a>

#### Description <a href="#description_7" id="description_7"></a>

Back color all series is a data series containing the background color for each bar. The difference to BackColorSeries is that the background color of the subchart is included.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_4" id="parameter_4"></a>

a color object of the type "public struct color"

int barsAgo

#### Usage <a href="#usage_6" id="usage_6"></a>

```csharp
BackColorAllSeries
BackColorAllSeries[int barsAgo]
```

When using the method with an index \[**int** barsAgo] the background color for the referenced bar will be changed or returned.

#### Example <a href="#example_6" id="example_6"></a>

See [*BackColorSeries*](#backcolorseries).

### BackColorSeries <a href="#backcolorseries" id="backcolorseries"></a>

#### Description <a href="#description_8" id="description_8"></a>

Back color series is a data series containing the background color for each bar. If the background color for the subcharts is to be included, please use "BackColorAllSeries" instead.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_5" id="parameter_5"></a>

a color object of the type "public struct color"

int barsAgo

#### Usage <a href="#usage_7" id="usage_7"></a>

```csharp
BackColorSeries
BackColorSeries[int barsAgo]
```

When using this method with an index \[**int** barsAgo] the background color for the referenced bar will be outputted.

#### Example <a href="#example_7" id="example_7"></a>

```csharp
// Which background color does the current bar have?
Print (BackColorSeries[0]);
// Set the current bar’s background color to blue
// This is identical to BackColor = Color.Blue
BackColorSeries[3] = Color.Blue;
// Set background color for the previous bar to green
BackColorSeries[1] = Color.Green;
```

### BarColor <a href="#barcolor" id="barcolor"></a>

#### Description <a href="#description_9" id="description_9"></a>

Bar color changes the color of a bar.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_6" id="parameter_6"></a>

a color object of the type "public struct color"

#### Usage <a href="#usage_8" id="usage_8"></a>

BarColor

#### Example <a href="#example_8" id="example_8"></a>

```csharp
// If the closing price is above the SMA(14), color the bar orange
if (Close[0] > SMA(14)[0]) BarColor = Color.Orange;
```

![BarColor](https://agenatrader.github.io/AgenaScript-documentation/media/image15.png)

### BarColorSeries <a href="#barcolorseries" id="barcolorseries"></a>

#### Description <a href="#description_10" id="description_10"></a>

Bar color series is a data series containing the color for each bar.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_7" id="parameter_7"></a>

a color object of the type "public struct color"

int barsAgo

#### Usage <a href="#usage_9" id="usage_9"></a>

BarColorSeries

BarColorSeries\[**int** barsAgo]

When using the method with an index \[**int** barsAgo] the color for the referenced bar will be changed or returned.

**Caution: Only the color of a bar whose color has been explicitly changed beforehand will be returned. In all other cases, the "Color.Empty" value will be returned.**

#### Example <a href="#example_9" id="example_9"></a>

```csharp
protected override void OnCalculate()
{
if (ProcessingBarIndex == Bars.Count-1-(CalculateOnClosedBar?1:0))
{
// Color the current bar blue
// This is identical to BarColor = color.Blue
BarColorSeries[0] = Color.Blue;
// Color the previous bars green
BarColorSeries[1] = Color.Orange;
// Color the third bar yellow
BarColorSeries[2] = Color.Yellow;
}
}
```

![BarColorSeries](https://agenatrader.github.io/AgenaScript-documentation/media/image19.png)

### CandleOutlineColor <a href="#candleoutlinecolor" id="candleoutlinecolor"></a>

#### Description <a href="#description_11" id="description_11"></a>

Candle outline color changes the border/outline color (including the wick) of a bar.

If the color of the bar is changed using BarColor and the outline is not changed using CandleOutlineColor, the outline color is adjusted to match the color of the bar.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_8" id="parameter_8"></a>

a color object of the type "public struct color"

#### Usage <a href="#usage_10" id="usage_10"></a>

CandleOutlineColor

#### Example <a href="#example_10" id="example_10"></a>

```csharp
if (SMA(14)[0] > SMA(200)[0])
CandleOutlineColor = Color.LimeGreen;
else
CandleOutlineColor = Color.Red;
```

![CandleOutlineColor](https://agenatrader.github.io/AgenaScript-documentation/media/image20.png)

### CandleOutlineColorSeries <a href="#candleoutlinecolorseries" id="candleoutlinecolorseries"></a>

#### Description <a href="#description_12" id="description_12"></a>

Candle outline color series is a data series that saves the outline color for each bar.

See [*Colors*](#colors), [*BarColor*](#barcolor), [*BackColor*](#backcolor),[ *BackColorAll*](#backcolorall), [*BarColorSeries*](#barcolorseries),[ *BackColorAll*](#backcolorall), [*CandleOutlineColor*](#candleoutlinecolor).

#### Parameter <a href="#parameter_9" id="parameter_9"></a>

a color object of the type "public struct color"

int barsAgo

#### Usage <a href="#usage_11" id="usage_11"></a>

```csharp
CandleOutlineColorSeries
CandleOutlineColorSeries[int barsAgo]
```

When using this method with an index \[**int** barsAgo] the border color for the referenced bar will be outputted.

**Caution: Color.Empty will be outputted for a bar unless it has been previously changed.**

#### Example <a href="#example_11" id="example_11"></a>

```csharp
// Set the outline color of the current bar to blue
CandleOutlineColorSeries[0] = Color.Blue;
// Change the outline color to the chart default value
CandleOutlineColorSeries[0] = Color.Empty;
```

### CrossAbove() <a href="#crossabove" id="crossabove"></a>

#### Description <a href="#description_13" id="description_13"></a>

The CrossAbove() method allows you to check whether a crossing of two values has occurred (from bottom to top) within a predefined number of periods. The values can be a market price, an indicator, a data series or a constant value.

See [*CrossAbove()*](#crossabove), [*CrossBelow()*](#crossbelow), [*IsSerieRising()*](#isserierising), [*IsSerieFalling()*](#isseriefalling).

#### Usage <a href="#usage_12" id="usage_12"></a>

```csharp
CrossAbove(IDataSeries series1, double value, int lookBackPeriod)
CrossAbove(IDataSeries series1, IDataSeries series2, int lookBackPeriod)
```

#### Return Value <a href="#return-value_1" id="return-value_1"></a>

**true** a cross has occurred **false** a cross has not occurred

#### Parameter <a href="#parameter_10" id="parameter_10"></a>

|                     |                                                          |
| ------------------- | -------------------------------------------------------- |
| lookBackPeriod      | Number of bars within which a cross will be searched for |
| series1 und series2 | A data series such as an indicator, close, high, etc.    |
| value               | A constant value of the type double                      |

#### Example <a href="#example_12" id="example_12"></a>

```csharp
// Puts out a notice if the SMA(20) crosses above the SMA(50)
if (CrossAbove(SMA(20), SMA(50), 1))
Print("SMA(20) has risen above SMA(50)!");
// Puts out a notice if the SMA(20) crosses above the value of 40
if (CrossAbove(SMA(20), 40, 1))
Print("SMA(20) has risen above 40!");
// Put out a notice for a long entry if the SMA(20) has crossed above the SMA(50) within the last 5 bars.
if (CrossAbove(SMA(20), SMA(50), 1) && Close[0] > Close[1])
Print("Long entry !!!");
```

### CrossBelow() <a href="#crossbelow" id="crossbelow"></a>

#### Description <a href="#description_14" id="description_14"></a>

Using the CrossBelow() method, you can test whether or not a cross below has occurred within a predefined number of periods. The values can be the market price, an indicator, any data series, or a constant value.

See [*CrossAbove()*](#crossabove), [*CrossBelow()*](#crossbelow), [*IsSerieRising()*](#isserierising), [*IsSerieFalling()*](#isseriefalling).

#### Usage <a href="#usage_13" id="usage_13"></a>

```csharp
CrossBelow(IDataSeries series1, double value, int lookBackPeriod)
CrossBelow(IDataSeries series1, IDataSeries series2, int lookBackPeriod)
```

#### Return Value <a href="#return-value_2" id="return-value_2"></a>

**true** a cross has occurred **false** a cross has not occurred

#### Parameter <a href="#parameter_11" id="parameter_11"></a>

|                     |                                                          |
| ------------------- | -------------------------------------------------------- |
| lookBackPeriod      | Number of Bars within which a cross will be searched for |
| series1 und series2 | A data series such as an indicator, close, high etc.     |
| value               | A constant value of the type double                      |

#### Example <a href="#example_13" id="example_13"></a>

```csharp
// Puts out a notice if the SMA(20) crosses below the SMA(50)
if (CrossBelow(SMA(20), SMA(50), 1))
Print("SMA(20) has fallen below SMA(50)!");
// Puts out a notice if the SMA(20) falls below the value of 40
if (CrossBelow(SMA(20), 40, 1))
Print("SMA(20) has fallen below 40!");
// Puts out a notice for a short entry if a crossing of the SMA(20) below the SMA(50) has occurred within the last 5 bars.
.
if (CrossBelow(SMA(20), SMA(50), 1) 
&& Instrument.Compare(Close[1], Close[0]) > 1)
Print("Short entry !!!");
```

### DatafeedHistoryPeriodicity <a href="#datafeedhistoryperiodicity" id="datafeedhistoryperiodicity"></a>

#### Description <a href="#description_15" id="description_15"></a>

Datafeed history periodicity is a data type.

#### Definition <a href="#definition" id="definition"></a>

public enum DatafeedHistoryPeriodicity - DatafeedHistoryPeriodicity.Tick - DatafeedHistoryPeriodicity.Second - DatafeedHistoryPeriodicity.Minute - DatafeedHistoryPeriodicity.Hour - DatafeedHistoryPeriodicity.Day - DatafeedHistoryPeriodicity.Week - DatafeedHistoryPeriodicity.Month - DatafeedHistoryPeriodicity.Volume - DatafeedHistoryPeriodicity.Range - DatafeedHistoryPeriodicity.Quarter - DatafeedHistoryPeriodicity.Year - DatafeedHistoryPeriodicity.HeikinAshi - DatafeedHistoryPeriodicity.Renko - DatafeedHistoryPeriodicity.LineBreak - DatafeedHistoryPeriodicity.Kagi - DatafeedHistoryPeriodicity.PointAndFigure - DatafeedHistoryPeriodicity.Custom

See *TimeFrame*, *TimeFrames*.

### DataSeries <a href="#dataseries" id="dataseries"></a>

#### Description <a href="#description_16" id="description_16"></a>

Data series (data rows) are an easy yet powerful method of saving additional values for individual bars. For example, when calculating the smoothing average, each bar is assigned the value calculated for this bar. A data series is an array that contains as many elements as there are bars displayed in a chart. AgenaTrader ensures that data series are correctly synchronized with the bars. Data series are used in exactly the same way as the close or time series. They can therefore also be used for the input data for various indicators. In the table below you will find 4 newly created data series (highlighted). Each data series has exactly one value of a special data type (int, bool, string) attached to it per bar. The indexing with barsAgo is thus identical to the data series provided by the system.

![DataSeries](https://agenatrader.github.io/AgenaScript-documentation/media/image12.png)

#### Usable Data Series in AgenaTrader <a href="#usable-data-series-in-agenatrader" id="usable-data-series-in-agenatrader"></a>

[*BoolSeries*](#boolseries)

[*DataSeries*](#dataseries)

[*DateTimeSeries*](#datetimeseries)

[*FloatSeries*](#floatseries)

[*IntSeries*](#intseries)

[*LongSeries*](#longseries)

[*StringSeries*](#stringseries)

In addition, there are also data series such as ColorSeries, although these are only used for internal purposes and should not be used directly. To change the color of plots, please use [*PlotColors*](https://agenatrader.github.io/AgenaScript-documentation/keywords/#plotcolors).

#### Set(), Reset() und ContainsValue() <a href="#set-reset-und-containsvalue" id="set-reset-und-containsvalue"></a>

Each data series contains a **Set()**, **Reset()** and **ContainsValue()** method. With Set(value) or Set(int barsAgo, value) you can place values into the data series for the current position, or in this case into the barsAgo position. With Reset() or Reset(int barsAgo) you can delete a value from the data series for the current position or for the barsAgo position. This has the result that no valid value exists at this position any more. Programming with the help of the reset method can simplify otherwise complex logic. This is especially true for Boolean series, where only "true" or "false" values can be included. The ContainsValue() checks whether a data series has a value for a specific position.

#### Information about Data Types <a href="#information-about-data-types" id="information-about-data-types"></a>

<https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types>

### BoolSeries <a href="#boolseries" id="boolseries"></a>

#### Description <a href="#description_17" id="description_17"></a>

Bool series is a data series that contains a Boolean value for each bar. The number of elements in this series correlates with the exact number of bars within the chart.

#### Create New Bool Series <a href="#create-new-bool-series" id="create-new-bool-series"></a>

In the area for the declaration of variables, simply declare a new variable:

```csharp
//Variable declaration
private BoolSeries myBoolSeries;
```

With the OnInit() method, this variable assigns a new instance of the Bool series:

```csharp
protected override void OnInit()
{
myBoolSeries = new BoolSeries(this);
CalculateOnClosedBar = true;
}
```

#### Assign Values <a href="#assign-values" id="assign-values"></a>

Assigning a value to the data series for the current position:

```csharp
myBoolSeries.Set(true);
```

Writing a value in the past into the data series:

```csharp
myBoolSeries.Set(int barsAgo, bool Value);
```

#### Delete Values <a href="#delete-values" id="delete-values"></a>

Removing the current value for the data series:

```csharp
myBoolSeries.Reset();
```

Removing a value in the past from the data series:

```csharp
myBoolSeries.Reset(int barsAgo);
```

#### Check Values for their Validity <a href="#check-values-for-their-validity" id="check-values-for-their-validity"></a>

```csharp
myBoolSeries.ContainsValue(int barsAgo);
```

#### Read Value <a href="#read-value" id="read-value"></a>

```csharp
Print ("For the bar of " + Time[0] + " ago the value of the data series is: " + myBoolSeries[0]);
```

#### Example <a href="#example_14" id="example_14"></a>

```csharp
protected override void OnCalculate()
{
if (Close[0] > Open[0])
myBoolSeries.Set(true);
else
myBoolSeries.Set(false);
}
```

### DataSeries <a href="#dataseries_1" id="dataseries_1"></a>

#### Description <a href="#description_18" id="description_18"></a>

Data series is a [*DataSeries*](#dataseries) that can contain a double value for each bar. The number of elements in this series corresponds to the exact number of bars within the charts.

Data series for double values are the data series most commonly used for indicators.

#### Create a New Data Series <a href="#create-a-new-data-series" id="create-a-new-data-series"></a>

In the declaration area for variables:

```csharp
//Variable declaration
private DataSeries myDataSeries;
```

With the OnInit() method, this variable is assigned a new instance:

```csharp
protected override void OnInit()
{
myDataSeries = new DataSeries(this);
CalculateOnClosedBar = true;
}
```

#### Assign Values <a href="#assign-values_1" id="assign-values_1"></a>

Assigning a value to the data series for the current position:

```csharp
myDataSeries.Set(Bars[0].Close);
```

Writing a value in the past into the data series:

```csharp
myDataSeries.Set(int barsAgo, double Value);
```

#### Delete Values <a href="#delete-values_1" id="delete-values_1"></a>

Removing the current value from the data series:

```csharp
myDataSeries.Reset();
```

Removing a value in the past from the data series:

```csharp
myDataSeries.Reset(int barsAgo);
```

#### Check Values for their Validity <a href="#check-values-for-their-validity_1" id="check-values-for-their-validity_1"></a>

```csharp
myDataSeries.ContainsValue(int barsAgo);
```

#### Read Value <a href="#read-value_1" id="read-value_1"></a>

```csharp
Print ("For the bar from " + Time[0] + " ago the value for the data series is: " + myDataSeries[0]);
```

#### Example <a href="#example_15" id="example_15"></a>

```csharp
//Saves the span between the high and low of a bar
myDataSeries.Set(Math.Abs(High[0]-Low[0]));
```

### DateTimeSeries <a href="#datetimeseries" id="datetimeseries"></a>

#### Description <a href="#description_19" id="description_19"></a>

Date time series is a [*DataSeries*](#dataseries) that can record a date time value for each bar. The number of elements in this series corresponds to the number of bars in the chart.

#### Create a New Data Series <a href="#create-a-new-data-series_1" id="create-a-new-data-series_1"></a>

Create a new variable in the declaration area:

```csharp
//Variable declaration
private DateTimeSeries myDataSeries;
```

Assign a new instance of DateTimeSeries for the variable with the OnInit() method:

```csharp
protected override void OnInit()
{
myDataSeries = new DateTimeSeries(this);
CalculateOnClosedBar = true;
}
```

#### Assign Values <a href="#assign-values_2" id="assign-values_2"></a>

Assigning a value to the current position of the data series:

```csharp
myDataSeries.Set(DateTime Value);
```

Writing a value from the past into the data series:

```csharp
myDataSeries.Set(int barsAgo, DateTime Value);
```

#### Delete Values <a href="#delete-values_2" id="delete-values_2"></a>

Removing the current value from the data series:

```csharp
myDataSeries.Reset();
```

Remove a past value from the data series:

```csharp
myDataSeries.Reset(int barsAgo);
```

#### Check Values for their Validity <a href="#check-values-for-their-validity_2" id="check-values-for-their-validity_2"></a>

```csharp
myDataSeries.ContainsValue(int barsAgo);
```

#### Read Value <a href="#read-value_2" id="read-value_2"></a>

```csharp
Print ("For the bar from " + Time[0] + " ago the value of the data series is: " + myDataSeries[0]);
```

#### Example <a href="#example_16" id="example_16"></a>

```csharp
//Saves the difference of -6 hours (eastern time, New York) for a time zone conversion
myDataSeries.Set(Time[0].AddHours(-6));
```

### FloatSeries <a href="#floatseries" id="floatseries"></a>

#### Description <a href="#description_20" id="description_20"></a>

Float series is a [*DataSeries*](#dataseries) that contains a float value for each bar in the chart. The number of elements in this series corresponds to the number of bars within the chart.

#### Create a New Data Series <a href="#create-a-new-data-series_2" id="create-a-new-data-series_2"></a>

Create a new variable in the declaration area:

```csharp
//Variable declaration
private FloatSeries myDataSeries;
```

Assign a new instance of the FloatSeries to the variable with the OnInit() method:

```csharp
protected override void OnInit()
{
myDatatSeries = new FloatSeries(this);
CalculateOnClosedBar = true;
}
```

#### Assign Values <a href="#assign-values_3" id="assign-values_3"></a>

Assigning a value to the current position of the data series

```csharp
myDataSeries.Set(float Value);
```

Writing a value from the past into the data series:

```csharp
myDataSeries.Set(int barsAgo, float Value);
```

#### Delete Values <a href="#delete-values_3" id="delete-values_3"></a>

Removing the current value from the data series:

```csharp
myDataSeries.Reset();
```

Removing a value located in the past from the data series:

```csharp
myDataSeries.Reset(int barsAgo);
```

#### Check Values for their Validity <a href="#check-values-for-their-validity_3" id="check-values-for-their-validity_3"></a>

```csharp
myDataSeries.ContainsValue(int barsAgo);
```

#### Read Value <a href="#read-value_3" id="read-value_3"></a>

```csharp
Print ("For the bar from " + Time[0] + " ago the value for the data series is: " + myDataSeries[0]);
```

#### Example <a href="#example_17" id="example_17"></a>

```csharp
//Saves the span between the high and the low of a bar
myDataSeries.Set(Math.Abs((float) High[0] - (float) Low[0]));
```

### IntSeries <a href="#intseries" id="intseries"></a>

#### Description <a href="#description_21" id="description_21"></a>

Int series is a [*DataSeries*](#dataseries) that can assign an integer value for each bar. The number of elements in this series corresponds to the number of bars within the chart.

#### Create a New Data Series <a href="#create-a-new-data-series_3" id="create-a-new-data-series_3"></a>

Create a new variable in the declaration area:

```csharp
//Variable declaration
private IntSeries myDataSeries;
```

Assign an instance of the int series to the variable with the OnInit() method:

```csharp
protected override void OnInit()
{
myDataSeries = new IntSeries(this);
CalculateOnClosedBar = true;
}
```

#### Assign Values <a href="#assign-values_4" id="assign-values_4"></a>

Assigning a value to the current position of the data series

```csharp
myDataSeries.Set(int Value);
```

Writing a value from the past into the data series:

```csharp
myDataSeries.Set(int barsAgo, int Value);
```

#### Delete Values <a href="#delete-values_4" id="delete-values_4"></a>

Removing the current value from the data series:

```csharp
myDataSeries.Reset();
```

Removing a value located in the past from the data series:

```csharp
myDataSeries.Reset(int barsAgo);
```

#### Check Values for their Validity <a href="#check-values-for-their-validity_4" id="check-values-for-their-validity_4"></a>

```csharp
myDataSeries.ContainsValue(int barsAgo);
```

#### Read Value <a href="#read-value_4" id="read-value_4"></a>

```csharp
Print (For the bar from + Time[0] + the value of the data series is:+ myDataSeries[0]);
```

#### Example <a href="#example_18" id="example_18"></a>

```csharp
//Saves the span in ticks between high and low for each bar
myDataSeries.Set((int) ((High[0] - Low[0]) / TickSize));
```

### LongSeries <a href="#longseries" id="longseries"></a>

#### Description <a href="#description_22" id="description_22"></a>

Long series is a [*DataSeries*](#dataseries) that can include an integer value for each bar. The number of elements in this series corresponds to the number of bars within the chart.

#### Create a New Data Series <a href="#create-a-new-data-series_4" id="create-a-new-data-series_4"></a>

Create a new variable in the declaration area:

```csharp
//Variable declaration
private LongSeries myDataSeries;
```

Assign a new instance of the long series to the variable with the OnInit() method:

```csharp
protected override void OnInit()
{
myDataSeries = new LongSeries(this);
CalculateOnClosedBar = true;
}
```

#### Assign Values <a href="#assign-values_5" id="assign-values_5"></a>

Assigning a value to the current position of the data series:

```csharp
myDataSeries.Set(long Value);
```

Writing a value from the past into the data deries:

```csharp
myDataSeries.Set(int barsAgo, long Value);
```

#### Delete Values <a href="#delete-values_5" id="delete-values_5"></a>

Removing the current value from the data series:

```csharp
myDataSeries.Reset();
```

Removing a value located in the past from the data series:

```csharp
myDataSeries.Reset(int barsAgo);
```

#### Check Values for their Validity <a href="#check-values-for-their-validity_5" id="check-values-for-their-validity_5"></a>

```csharp
myDataSeries.ContainsValue(int barsAgo);
```

#### Read Value <a href="#read-value_5" id="read-value_5"></a>

```csharp
Print (For the bar from + Time[0] + the value of the data series is:+ myDataSeries[0]);
```

#### Example <a href="#example_19" id="example_19"></a>

```csharp
//Saves the span of ticks between high and low for each bar
myDataSeries.Set((long) ((High[0] - Low[0]) / TickSize));
```

### StringSeries <a href="#stringseries" id="stringseries"></a>

#### Description <a href="#description_23" id="description_23"></a>

String series is a [*DataSeries*](#dataseries) for string values that are saved for each bar. The number of elements in this series corresponds to the number of bars within the chart.

#### Create a New Data Series <a href="#create-a-new-data-series_5" id="create-a-new-data-series_5"></a>

Create a new variable in the declaration area:

```csharp
//Variable declaration
private StringSeries myDataSeries;
```

Assign an instance of string series to the variable with the OnInit() method:

```csharp
protected override void OnInit()
{
myDataSeries = new StringSeries(this);
CalculateOnClosedBar = true;
}
```

#### Assign Values <a href="#assign-values_6" id="assign-values_6"></a>

Assigning a value to the current position of the data series:

```csharp
myDataSeries.Set(string Value);
```

Writing a value from the past into the data series:

```csharp
myDataSeries.Set(int barsAgo, string Value);
```

#### Delete Values <a href="#delete-values_6" id="delete-values_6"></a>

Remove the current value from the data series:

```csharp
myDataSeries.Reset();
```

Remove a value located in the past from the data series:

```csharp
myDataSeries.Reset(int barsAgo);
```

#### Check Values for their Validity <a href="#check-values-for-their-validity_6" id="check-values-for-their-validity_6"></a>

```csharp
myDataSeries.ContainsValue(int barsAgo);
```

#### Read Value <a href="#read-value_6" id="read-value_6"></a>

```csharp
Print (For the bar from + Time[0] + the value of the data series is:+ myDataSeries[0]);
```

#### Example <a href="#example_20" id="example_20"></a>

```csharp
//Save the current calendar day for each bar (Monday… Tuesday etc.)
myDataSeries.Set(string.Format("{0:dddd}", Time[0]));
```

### DayOfWeek <a href="#dayofweek" id="dayofweek"></a>

#### Description <a href="#description_24" id="description_24"></a>

"DayOfWeek" outputs the date-time value (such as a timestamp) for each bar.

Of course, all other methods defined within the C# language for usage of date-time objects are also available, such as day, month, year, hour, minute, second, day of week etc.

See <https://learn.microsoft.com/en-us/dotnet/api/system.datetime.dayofweek?view=net-8.0>

#### Definition <a href="#definition_1" id="definition_1"></a>

Property DayOfWeek

public enum DayOfWeek - DayOfWeek.Monday - DayOfWeek.Tuesday - DayOfWeek.Wednesday - DayOfWeek.Thursday - DayOfWeek.Friday - DayOfWeek.Saturday - DayOfWeek.Sunday

#### Example <a href="#example_21" id="example_21"></a>

```csharp
//Outputs the weekday for each bar
Print(Time[0].DayOfWeek);
//Do not execute trades on a Friday
if (Time[0].DayOfWeek == DayOfWeek.Friday)
return;
```

### Displacement <a href="#displacement" id="displacement"></a>

#### Description <a href="#description_25" id="description_25"></a>

By implementing "Displacement", you can shift a drawn indicator line right or left along the x-axis. This property can be queried within the script and will return an int value.

Blue line: Displacement = 0 (Original) Red line: Displacement = -5 Green line: Displacement = +5

![Displacement](https://agenatrader.github.io/AgenaScript-documentation/media/image13.png)

#### Usage <a href="#usage_14" id="usage_14"></a>

Displacement

#### Parameter <a href="#parameter_12" id="parameter_12"></a>

int Offset Number of bars by which the indicator is to be moved.

#### Example <a href="#example_22" id="example_22"></a>

```csharp
protected override void OnInit()
{
AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
//Displacement of the plot by one bar to the right
Displacement = 1;
}
```

### Email function <a href="#email-function" id="email-function"></a>

#### Description <a href="#description_26" id="description_26"></a>

Override method which allows to send mail.

#### Parameter <a href="#parameter_13" id="parameter_13"></a>

None

#### Return value <a href="#return-value_3" id="return-value_3"></a>

string

#### Usage <a href="#usage_15" id="usage_15"></a>

used for complicated calculation on a last bar

#### Example <a href="#example_23" id="example_23"></a>

```csharp
protected override void OnOrderExecution(IExecution execution)
{
if (execution.Order != null && execution.Order.OrderState == OrderState.FilledQuantity)
{
if (oEnter != null && execution.Name == oEnter.Name)
{
// Enter-Order gefüllt
if (_sendMail) this.SendEmail(Core.AccountManager.Core.Settings.MailDefaultFromAddress, Core.PreferenceManager.DefaultEmailAddress,
execution.Instrument.Symbol + " order " + execution.Name + " executed.", "The order for " + execution.Instrument.Name + " was executed. Invest: " + (Trade.Quantity * Trade.AvgPrice).ToString("F2"));
}
else if (oTStop != null && execution.Name == oTStop.Name)
{
OrderStatus = 0; // Trend-Stopp-Order gefüllt
if (_sendMail) this.SendEmail(Core.AccountManager.Core.Settings.MailDefaultFromAddress, Core.PreferenceManager.DefaultEmailAddress,
execution.Instrument.Symbol +" order " + execution.Name + " executed.",
execution.Instrument.Symbol +" order " + execution.Name + " executed. Profit:" + Trade.ClosedProfitLoss.ToString("F2"));
}
}
}
```

### FirstTickOfBar <a href="#firsttickofbar" id="firsttickofbar"></a>

#### Description <a href="#description_27" id="description_27"></a>

FirstTickOfBar is a property of the type "bool" that returns "true" if the currently incoming tick is associated with a new bar. This means that this tick is the first tick of a new bar. This property can only be meaningfully applied when the indicator or strategy is running in the tick-by-tick mode, meaning that CalculateOnClosedBar = false and the data feed is able to output real-time values. When using end-of-day data in a daily chart, the "FirstTickOfBar" is always true for the last bar. FirstTickOfBar should not be used outside of the OnCalculate() method. See [*Bars.TicksCountForLastBar*.](/handling-bars-and-instruments/bars.md#barstickscountforlastbar)

#### Usage <a href="#usage_16" id="usage_16"></a>

FirstTickOfBar

#### Example <a href="#example_24" id="example_24"></a>

```csharp
// Within a tick-by-tick strategy, execute one part bar-by-bar only
if (FirstTickOfBar)
{
if (CCI(20)[1] < -250)
OpenLong();
return;
}
```

### FirstTickOfBarMtf <a href="#firsttickofbarmtf" id="firsttickofbarmtf"></a>

#### Description <a href="#description_28" id="description_28"></a>

FirstTickOfBarMtf is the **multi-time frame** variant of the [*FirstTickOfBar* ](#firsttickofbar)property.

The setting of CalculateOnClosedBar only affects the primary timeframe (chart timeframe). When working with multi-bars, the ticks of the secondary timeframes are provided on a tick-by-tick basis independently of the CalculateOnClosedBar setting. With the help of FirstTickOfBarMtf, it is possible to determine when a new bar has begun in a secondary timeframe.

#### Usage <a href="#usage_17" id="usage_17"></a>

FirstTickOfBarMtf(ProcessingBarSeriesIndex)

#### Parameter <a href="#parameter_14" id="parameter_14"></a>

FirstTickOfBarMtf(ProcessingBarSeriesIndex).

See [*ProcessingBarSeriesIndex*.](#processingbarindex)

#### Example <a href="#example_25" id="example_25"></a>

```csharp
if (FirstTickOfBarMtf(ProcessingBarSeriesIndex))
Print("A new bar has begun.");
```

### GetCurrentAsk() <a href="#getcurrentask" id="getcurrentask"></a>

#### Description <a href="#description_29" id="description_29"></a>

The GetCurrentAsk() method returns the current value of the ask side of the order book. If no level 1 data is available to AgenaTrader, then this function simply outputs the last trade value.

See [*GetCurrentBid()*](#getcurrentbid) and [*OnLevel1()*](/events.md#onlevel1).

#### Usage <a href="#usage_18" id="usage_18"></a>

GetCurrentAsk()

#### Return Value <a href="#return-value_4" id="return-value_4"></a>

double value

#### Parameter <a href="#parameter_15" id="parameter_15"></a>

none

#### Example <a href="#example_26" id="example_26"></a>

```csharp
If an entry condition is fulfilled, then 1 contract should be sold at the current ask price:
private IOrder entryOrder = null;
protected override void OnCalculate()
{
// Entry condition
if (Close[0] < SMA(20)[0] && entryOrder == null)
// Sell 1 contract at the current ask price

    SubmitOrder(new StrategyOrderParameters
                {
                    Direction = OrderDirection.Sell,
                    Type = OrderType.Limit,
                    Mode = OrderMode.Direct,
                    Price = GetCurrentAsk(),
                    Quantity = 1,
                    SignalName = "Enter short",
                    Instrument = Instrument,
                    TimeFrame = TimeFrame,
                    LiveUntilCancelled = true
                });
}
```

### GetCurrentAskVolume() <a href="#getcurrentaskvolume" id="getcurrentaskvolume"></a>

#### Description <a href="#description_30" id="description_30"></a>

The GetCurrentAskVolume () method returns the current volume on the Ask page of the order book. This function is only executable if the data provider provides level 2 data.

See [*GetCurrentBidVolume()*](#getcurrentbidvolume), [*GetCurrentBid()* ](#getcurrentbid)and [*OnLevel1()*](/events.md#onlevel1).

#### Usage <a href="#usage_19" id="usage_19"></a>

GetCurrentAskVolume()

#### Return Value <a href="#return-value_5" id="return-value_5"></a>

Long value

#### Parameter <a href="#parameter_16" id="parameter_16"></a>

none

#### Example <a href="#example_27" id="example_27"></a>

```csharp
protected override void OnCalculate()
{
   if (GetCurrentAskVolume() < GetCurrentBidVolume())
       Print("AskVolume {0} < BidVolume {1}", GetCurrentAskVolume(), GetCurrentBidVolume());
}
```

### GetCurrentBid() <a href="#getcurrentbid" id="getcurrentbid"></a>

#### Description <a href="#description_31" id="description_31"></a>

The GetCurrentBid() method returns the current value of the bid side of the order book. If no level 1 data is available to AgenaTrader, then the function outputs the last traded price.

See [*GetCurrentAsk()*](#getcurrentask) and [*OnLevel1()*](/events.md#onlevel1).

#### Usage <a href="#usage_20" id="usage_20"></a>

GetCurrentBid()

#### Return Value <a href="#return-value_6" id="return-value_6"></a>

double value

#### Parameter <a href="#parameter_17" id="parameter_17"></a>

none

#### Example <a href="#example_28" id="example_28"></a>

If an entry condition is fulfilled, then 1 contract should be sold at the current bid price:

```csharp
private IOrder entryOrder = null;
protected override void OnCalculate()
{
// Entry condition
if (Instrument.Compare(Close[0], SMA(20)[0]) > 0 && entryOrder == null)
// Sell 1 contract at the current bid price

  SubmitOrder(new StrategyOrderParameters
                {
                    Direction = OrderDirection.Buy,
                    Type = OrderType.Limit,
                    Mode = OrderMode.Direct,
                    Price = GetCurrentBid(),
                    Quantity = 1,
                    SignalName = "Enter long",
                    Instrument = Instrument,
                    TimeFrame = TimeFrame,
                    LiveUntilCancelled = true
                });
}
```

### GetCurrentBidVolume() <a href="#getcurrentbidvolume" id="getcurrentbidvolume"></a>

#### Description <a href="#description_32" id="description_32"></a>

The GetCurrentBidVolume () method returns the current volume on the Bid page of the order book. This function is only executable if the data provider provides level 2 data.

See [*GetCurrentAskVolume*](#getcurrentaskvolume), [*GetCurrentBid()*](#getcurrentbid) and [*OnLevel1()*](/events.md#onlevel1).

#### Usage <a href="#usage_21" id="usage_21"></a>

GetCurrentBidVolume()

#### Return Value <a href="#return-value_7" id="return-value_7"></a>

Long value

#### Parameter <a href="#parameter_18" id="parameter_18"></a>

none

#### Example <a href="#example_29" id="example_29"></a>

```csharp
protected override void OnCalculate()
{
   if (GetCurrentAskVolume() < GetCurrentBidVolume())
       Print("AskVolume {0} < BidVolume {1}", GetCurrentAskVolume(), GetCurrentBidVolume());
}
```

### GetCurrentPrice() <a href="#getcurrentprice" id="getcurrentprice"></a>

#### Description <a href="#description_33" id="description_33"></a>

The GetCurrentPrice() method returns the current price (Latest). If AgenaTrader does not have Level1 data, the function returns the price of the last sales

See [*GetCurrentAsk*](#getcurrentask), [*GetCurrentBid()*](#getcurrentbid) and [*OnLevel1()*](/events.md#onlevel1).

#### Usage <a href="#usage_22" id="usage_22"></a>

GetCurrentPrice()

#### Return Value <a href="#return-value_8" id="return-value_8"></a>

none

#### Parameter <a href="#parameter_19" id="parameter_19"></a>

double

#### Example <a href="#example_30" id="example_30"></a>

If an initial condition is fulfilled, 1 contract should be purchased at the current exchange rate.

```csharp
private IOrder entryOrder = null;

protected override void OnCalculate()
{

   .....

   // Einstiegsbedingung
   if (Instrument.Compare(Close[0], SMA(20)[0]) > 0 && entryOrder == null)
       // Kauf 1 Kontrakt zum aktuellen BidKurs
       entryOrder = SubmitOrder(new StrategyOrderParameters
                {
                    Direction = OrderDirection.Buy,
                    Type = OrderType.Limit,
                    Mode = OrderMode.Direct,
                    Price = GetCurrentBid(),
                    Quantity = 1,
                    SignalName = "EntryLong",
                    Instrument = Instrument,
                    TimeFrame = TimeFrame,
                    LiveUntilCancelled = true
                });
}
```

### GetCurrentSpread() <a href="#getcurrentspread" id="getcurrentspread"></a>

#### Description <a href="#description_34" id="description_34"></a>

The GetCurrentSpare () method returns the current spread.

See [*GetCurrentAsk*](#getcurrentask), [*GetCurrentBid()*](#getcurrentbid) and [*OnLevel1()*](/events.md#onlevel1).

#### Usage <a href="#usage_23" id="usage_23"></a>

GetCurrentSpread()

#### Return Value <a href="#return-value_9" id="return-value_9"></a>

none

#### Parameter <a href="#parameter_20" id="parameter_20"></a>

double

#### Example <a href="#example_31" id="example_31"></a>

If an initial condition is fulfilled, 1 contract should be purchased at the current exchange rate.

```csharp
protected override void OnCalculate()
{
       Print("Der aktuelle Spread ist {0}", GetCurrentSpread());
}
```

### GetDayAsInt() <a href="#getdayasint" id="getdayasint"></a>

#### Description <a href="#description_35" id="description_35"></a>

To day is a method specifically suited for inexperienced programmers who have problems with the potentially complex .net date-time structure of C#. Experienced programmers can continue using the date-time function directly.

To day outputs an int representation in the format of yyyymmdd. (yyyy = year, mm = month, dd = day)

13.08.2012 would thus be 20120813.

See [*GetTimeAsInt*.](#gettimeasint)

Help with date-time: <https://learn.microsoft.com/de-de/dotnet/api/system.datetime?view=net-8.0>

#### Usage <a href="#usage_24" id="usage_24"></a>

GetDayAsInt(DateTime time)

#### Example <a href="#example_32" id="example_32"></a>

```csharp
// Do not trade on the 11<sup>th</sup> of September
if (GetDayAsInt(Time[0]) = 20130911)
return;
```

### GetSeriesHighestValue <a href="#getserieshighestvalue" id="getserieshighestvalue"></a>

#### Description <a href="#description_36" id="description_36"></a>

The GetSeriesHighestValue() method searches within a predetermined number of periods for the highest bar and outputs how many bars ago it can be found.

See [*GetSeriesLowestValue()*.](#getserieslowestvalue)

#### Parameter <a href="#parameter_21" id="parameter_21"></a>

period Number of bars within which the bar is searched for

series Every data series, such as close, high, low, etc.

#### Return Value <a href="#return-value_10" id="return-value_10"></a>

```csharp
int barsAgo How many bars ago the high occurred
```

#### Usage <a href="#usage_25" id="usage_25"></a>

```csharp
GetSeriesHighestValue(IDataSeries series, int period)
```

#### Example <a href="#example_33" id="example_33"></a>

```csharp
// How many bars ago was the highest high for the current session?
Print(GetSeriesHighestValue(High, Bars.BarsCountForSession - 1));
// What value did the market price have at the highest high of the session?
Print("The highest price for the session was: " + Open[GetSeriesHighestValue(High, Bars.BarsCountForSession - 1)]);
```

### GetSeriesLowestValue <a href="#getserieslowestvalue" id="getserieslowestvalue"></a>

#### Description <a href="#description_37" id="description_37"></a>

The GetSeriesLowestValue() method attempts to find the lowest bar within a predefined number of periods.

See [*GetSeriesHighestValue()*.](#getserieshighestvalue)

#### Parameter <a href="#parameter_22" id="parameter_22"></a>

period Number of bars that will be searched for the lowest bar

series Every data series, such as close, high, low etc.

#### Return Value <a href="#return-value_11" id="return-value_11"></a>

**int** barsAgo How many bars ago the low occurred

#### Usage <a href="#usage_26" id="usage_26"></a>

```csharp
GetSeriesLowestValue(IDataSeries series, int period)
```

#### Example <a href="#example_34" id="example_34"></a>

```csharp
// How many bars ago was the lowest low of the session?
Print(GetSeriesLowestValue(Low, Bars.BarsCountForSession - 1));
// Which price did the lowest open of the current session have?
Print("The lowest open price of the current session was: " + Open[GetSeriesLowestValue(Low, Bars.BarsCountForSession - 1)]);
```

### GetTimeAsInt() <a href="#gettimeasint" id="gettimeasint"></a>

#### Description <a href="#description_38" id="description_38"></a>

To time is a method specifically suited for inexperienced programmers who have problems with the potentially complex .net date-time structure of C#.

To time outputs an int representation in the format hhmmss. (hh = hour, mm = minute, ss = seconds)

The time 07:30 will be displayed as 73000 and 14:15:12 will become 141512.

See [*GetDayAsInt*](#getdayasint).

Help with date-time: [*http://msdn.microsoft.com/de-de/library/system.datetime.aspx*](http://msdn.microsoft.com/de-de/library/system.datetime.aspx)

#### Usage <a href="#usage_27" id="usage_27"></a>

GetTimeAsInt(DateTime time)

#### Example <a href="#example_35" id="example_35"></a>

```csharp
// Only enter trades between 08:15 and 16:35
if (GetTimeAsInt(Time[0]) >= 81500 && GetTimeAsInt(Time[0]) <= 163500)
{
// Any trading technique
}
```

### Historical <a href="#historical" id="historical"></a>

#### Description <a href="#description_39" id="description_39"></a>

Historical allows you to check whether AgenaScript is working with historical or real-time data. As long as OnCalculate() is called up for historical data, then historical = true. As soon as live data is being used, then historical = false. During a backtest, historical is always true.

#### Usage <a href="#usage_28" id="usage_28"></a>

Historical

#### Return Value <a href="#return-value_12" id="return-value_12"></a>

**true** when using historical data **false** when using real-time data

#### Example <a href="#example_36" id="example_36"></a>

```csharp
protected override void OnCalculate()
{
// only execute for real-time data
if (IsHistoricalMode) return;
// Trading technique
}
```

### InputPriceType <a href="#inputpricetype" id="inputpricetype"></a>

#### Description <a href="#description_40" id="description_40"></a>

The input price type property determines which price series is used by default when calculating an indicator, if no other data series is explicitly stated. InputPriceType can be set with the OnInit() method; this specification is then valid for all further calculations. If InputPriceType is in OnCalculate(), these changes are only valid starting with the next instruction. Every further appearance of InputPriceType will be ignored!

See [*PriceType*](#pricetype)

#### Usage <a href="#usage_29" id="usage_29"></a>

```csharp
InputPriceType
```

#### Example1 <a href="#example1" id="example1"></a>

```csharp
protected override void OnInit()
{
ClearTraceWindow();
InputPriceType = PriceType.Low;
}
protected override void OnCalculate()
{
// The input data series for the indicator (InSeries) is low
Print(Low[0] + " " + InSeries[0] + " " + InputPriceType);
}
```

#### Example2 <a href="#example2" id="example2"></a>

```csharp
protected override void OnCalculate()
{
// These values are identical
// since close is used as the input data series by default
Print(SMA(20)[0] + " " + SMA(Close, 20)[0]);
InputPriceType = PriceType.Low;
// From here on out, low is used instead of close
// Both values are identical
Print(SMA(20)[0] + " " + SMA(Low, 20)[0]);
InputPriceType = PriceType.High;
// The instructions will be ignored
// InSeries = low is still in effect
}
```

### Instrument <a href="#instrument" id="instrument"></a>

#### Description <a href="#description_41" id="description_41"></a>

With "instrument", information concerning the trading instrument (stock, future etc.) is made available.

Detailed information can be found here: *Instruments*.

### IsAddDrawingsToPricePanel <a href="#isadddrawingstopricepanel" id="isadddrawingstopricepanel"></a>

#### Description <a href="#description_42" id="description_42"></a>

The property "IsAddDrawingsToPricePanel" determines the panel in which the drawing objects are drawn.

```csharp
IsAddDrawingsToPricePanel = true (default)
```

Drawing objects are shown in the price chart

```csharp
IsAddDrawingsToPricePanel = false
```

Drawing objects are drawn in the panel (subchart) assigned to the indicator

If the indicator is already assigned to the price chart (overlay = true) then this property has no effect, meaning that no additional subchart is opened. The property can be queried within the script and returns a Boolean value.

#### Usage <a href="#usage_30" id="usage_30"></a>

IsAddDrawingsToPricePanel

#### Example <a href="#example_37" id="example_37"></a>

```csharp
protected override void OnInit()
{
// Indicator is drawn in a new subchart
IsOverlay = false;
       AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
// Drawing object is drawn in the price chart
IsAddDrawingsToPricePanel = true;
}
protected override void OnCalculate()
{
// Draws a vertical line in the price chart for the bar from 5 minutes ago
AddChartVerticalLine("MyVerticalLine", 5, Color.Black);
}
```

### IsAutoAdjustableScale <a href="#isautoadjustablescale" id="isautoadjustablescale"></a>

#### Description <a href="#description_43" id="description_43"></a>

IsAutoAdjustableScale is a property of indicators that can be set within the OnInit() method.

```csharp
IsAutoAdjustableScale = true (default)
```

The price axis (y-axis) of the chart is set so that all plots and lines of an indicator are visible.

```csharp
IsAutoAdjustableScale = false
```

Plots and lines of an indicator or strategy are not accounted for in the scaling of the y-axis. Therefore they may lie outside of the visible chart area.

This property can be queried and will return either "true" or "false".

#### Usage <a href="#usage_31" id="usage_31"></a>

IsAutoAdjustableScale

#### Example <a href="#example_38" id="example_38"></a>

```csharp
protected override void OnInit()
{
//Scale the chart so that all drawing objects are visible
IsAutoAdjustableScale = true;
}
```

### IsOverlay <a href="#isoverlay" id="isoverlay"></a>

#### Description <a href="#description_44" id="description_44"></a>

The overlay property defines whether the indicator outputs are displayed in the price chart above the bars or whether a separate chart window is opened below the charting area.

This property can be queried within the script and outputs a value of the type Boolean (true or false).

Please bear in mind that this property is only set once during the first OnInit() method. You are not able to change the value later in your script. So if you have disabled the indicator output box below the charting area using this property during OnInit() you need to enable it manually.

#### Usage <a href="#usage_32" id="usage_32"></a>

```csharp
IsOverlay = true // -> The indicator is drawn in front of the price (e.g. the SMA indicator)
```

```csharp
IsOverlay = false // -> A separate window below the chart is opened (e.g. the RSI indicator)
```

#### Example <a href="#example_39" id="example_39"></a>

```csharp
protected override void OnInit()
{
       AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
       
       //The indicator should be displayed within a separate window
       IsOverlay = false;
}
```

### IsProcessingBarIndexLast <a href="#isprocessingbarindexlast" id="isprocessingbarindexlast"></a>

#### Description <a href="#description_45" id="description_45"></a>

Indicates if current bar is last in calculation.

#### Parameter <a href="#parameter_23" id="parameter_23"></a>

None

#### Return value <a href="#return-value_13" id="return-value_13"></a>

Type bool

#### Usage <a href="#usage_33" id="usage_33"></a>

used for complicated calculation on a last bar

#### Example <a href="#example_40" id="example_40"></a>

```csharp
protected override void OnCalculate()
{
            base.OnCalculate();
            if (!IsProcessingBarIndexLast)
                return;
            bool isUpdated;
}
```

### IsSerieRising() <a href="#isserierising" id="isserierising"></a>

#### Description <a href="#description_46" id="description_46"></a>

With this method you can check if an uptrend exists, i.e. if the current value is bigger than the previous bar’s value.

See [*CrossAbove()*](#crossabove), [*CrossBelow()*](#crossbelow), [*IsSerieRising()*](#isserierising), [*IsSerieFalling()*](#isseriefalling).

#### Usage <a href="#usage_34" id="usage_34"></a>

```csharp
IsSerieRising(IDataSeries series)
```

#### Return Value <a href="#return-value_14" id="return-value_14"></a>

**true** If the data series is rising **false** If the data series is not rising

#### Parameter <a href="#parameter_24" id="parameter_24"></a>

series A data series such as an indicator, close, high etc.

#### Example <a href="#example_41" id="example_41"></a>

```csharp
// Check if SMA(20) is rising
if (IsSerieRising(SMA(20)))
Print("The SMA(20) is currently rising.");
```

### IsSerieFalling() <a href="#isseriefalling" id="isseriefalling"></a>

#### Description <a href="#description_47" id="description_47"></a>

The IsSerieFalling() method allows you to test whether an "is falling" condition exists, i.e. whether the current value is smaller than the value of the previous bar.

See [*CrossAbove()*](#crossabove), [*CrossBelow()*](#crossbelow), [*IsSerieRising()*](#isserierising), [*IsSerieFalling()*](#isseriefalling).

#### Usage <a href="#usage_35" id="usage_35"></a>

```csharp
IsSerieFalling(IDataSeries series)
```

#### Return Value <a href="#return-value_15" id="return-value_15"></a>

**true** If the data series is falling **false** If the data series is not falling

#### Parameter <a href="#parameter_25" id="parameter_25"></a>

series a data series such as an indicator, close, high etc.

#### Example <a href="#example_42" id="example_42"></a>

```csharp
// Check whether SMA(20) is falling
if (IsSerieFalling(SMA(20)))
Print("The SMA(20) is currently falling.");
```

### IsShowChartVerticalGrid <a href="#isshowchartverticalgrid" id="isshowchartverticalgrid"></a>

#### Description <a href="#description_48" id="description_48"></a>

The property IsShowChartVerticalGrid defines whether or not the regularly spaced vertical lines (the so-called grid) are shown within the charting area.

**IsShowChartVerticalGrid = true (default)**

Vertical grid lines are shown

**IsShowChartVerticalGrid = false**

Vertical grid lines are not shown

This property can be queried within the script and returns a value of the type Boolean (true or false).

#### Usage <a href="#usage_36" id="usage_36"></a>

IsShowChartVerticalGrid

#### Example <a href="#example_43" id="example_43"></a>

```csharp
protected override void OnInit()
{
       AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
// Vertical grid lines shall not be shown within the chart
IsShowChartVerticalGrid = false;
}
```

### IsShowInDataBox <a href="#isshowindatabox" id="isshowindatabox"></a>

#### Description <a href="#description_49" id="description_49"></a>

The property "IsShowInDataBox" states whether the value of an indicator is contained in the data box of the chart or not.

The property can be queried in the script and returns a value of the type Boolean (true or false).

```csharp
IsShowInDataBox = true (default)
```

The indicator values are displayed in the data box.

```csharp
IsShowInDataBox = false
```

The indicator values are not displayed in the data box.

The following image displays the values of 3 smoothed averages in the data box.

![IsShowInDataBox](https://agenatrader.github.io/AgenaScript-documentation/media/image14.png)

#### Usage <a href="#usage_37" id="usage_37"></a>

IsShowInDataBox

#### Example <a href="#example_44" id="example_44"></a>

```csharp
protected override void OnInit()
{
 AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
//Values will not be shown in the data box
IsShowInDataBox = false;
}
```

### IsShowPriceMarkers <a href="#isshowpricemarkers" id="isshowpricemarkers"></a>

#### Description <a href="#description_50" id="description_50"></a>

The paint price markers property defines whether the so-called price markers for the indicator outputs are displayed on the right-hand chart border (in the price axis) or not. In some cases it makes sense to switch these off for a better overview in the chart. **IsShowPriceMarkers = true (default)**

Price markers are shown in the price axis

**IsShowPriceMarkers = false**

Price markers are not shown in the price axis

This property can be queried within the script and returns a value of the type Boolean (true or false).

#### Usage <a href="#usage_38" id="usage_38"></a>

IsShowPriceMarkers

#### Example <a href="#example_45" id="example_45"></a>

```csharp
protected override void OnInit()
{

AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Black), "MyPlot1"));
//Do not show price markers in the price axis
IsShowPriceMarkers = false;
}
```

### Level1Args <a href="#level1args" id="level1args"></a>

#### Description <a href="#description_51" id="description_51"></a>

The data type Level1Args represents a change in the level 1 data and is used as a parameter of the OnLevel1() function.

|                |                                                                                                                                                          |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AskSize        | Current order volume on the ask side                                                                                                                     |
| AskPrice       | Current ask price                                                                                                                                        |
| BidSize        | Current order volume on the bid side                                                                                                                     |
| BidPrice       | Current bid price.                                                                                                                                       |
| Instrument     | An object of the type instrument that contains the trading instrument for which the level 1 data is outputted. See *Instruments*                         |
| LastPrice      | Last traded price                                                                                                                                        |
| MarketDataType | Potential values are: MarketDataType.Ask, MarketDataType.AskSize, MarketDataType.Bid, MarketDataType.BidSize, MarketDataType.Last, MarketDataType.Volume |
| Price          | This is equal to last price. This field only exists for compatability reasons                                                                            |
| Time           | A date-time value containing the timestamp of the change                                                                                                 |
| Volume         | A long value that shows the volume                                                                                                                       |

#### Example <a href="#example_46" id="example_46"></a>

See [*OnLevel1()*](/events.md#onlevel1).

### Level2Args <a href="#level2args" id="level2args"></a>

#### Description <a href="#description_52" id="description_52"></a>

The data type Level2Args represents a change in the level 2 data (market depth) and is used as a parameter within OnLevel2().

|                |                                                                                                                                 |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| MarketDataType | Potential values are: MarketDataType.Ask, MarketDataType.Bid                                                                    |
| MarketMaker    | A string value containing the market maker ID                                                                                   |
| Position       | An int value that defines the position within the market depth                                                                  |
| Operation      | Represents the action caused by a change in the order book. Values can be: Operation.Insert, Operation.Remove, Operation.Update |
| Price          | A double value that displays the bid/ask price                                                                                  |
| Time           | A date-time value containing the timestamp of the change                                                                        |
| Volume         | A long value that shows the volume                                                                                              |

#### Example <a href="#example_47" id="example_47"></a>

See [*OnLevel2()*](/events.md#onlevel2).

### LevelLine() <a href="#levelline" id="levelline"></a>

#### Description <a href="#description_53" id="description_53"></a>

A line object is used for drawing a horizontal line in the chart. Usually, these are upper and lower trigger lines for indicators such as the RSI (70 and 30). The lines described here are not to be confused with lines from the drawing objects (see "AddChartHorizontalLine"). LevelLine objects can be added to an indicator with the help of the Add() method, and with this, added to the lines collection.

See [*OutputDescriptor*](#outputdescriptor).

#### Parameter <a href="#parameter_26" id="parameter_26"></a>

|       |                                                              |
| ----- | ------------------------------------------------------------ |
| Color | LevelLine color                                              |
| Name  | Description                                                  |
| Pen   | A pen object                                                 |
| Value | Defines which value on the y-axis the line will be drawn for |

#### Usage <a href="#usage_39" id="usage_39"></a>

```csharp
LevelLine(Color color, double value, string name)
LevelLine(Pen pen, double value, string name)
```

#### More Information <a href="#more-information_1" id="more-information_1"></a>

Information on the pen class: <https://learn.microsoft.com/de-de/dotnet/api/system.drawing.pen?view=dotnet-plat-ext-8.0>

#### Example <a href="#example_48" id="example_48"></a>

```csharp
// Example 1
// A new line with standard values drawn at the value of 70
Add(new LevelLine(Color.Black, 70, "Upper"));
// Example 2
// A new line with self-defined values
private LevelLine line;
private Pen pen;
protected override void OnInit()
{
// Define a red pen with the line strength 1
pen = new Pen(Color.Red, 1);
// Define a horizontal line at 10
line = new LevelLine(pen, 10, "MyLine");
// add the defined line to the indicator
Add(line);
}
// Example 3
// Short form for the line in example 2
Add(new LevelLine(new Pen(Color.Red, 1), 10, "MyLine"));
```

### Log() <a href="#log" id="log"></a>

#### Description <a href="#description_54" id="description_54"></a>

Log() allows you to write outputs in the AgenaTrader log file (log tab). 5 different log levels are supported.

Note: If the log tab is not viewable, it can be displayed using the tools log.

#### Usage <a href="#usage_40" id="usage_40"></a>

```csharp
**Log**(string message, LogLevel logLevel)
```

#### Parameter <a href="#parameter_27" id="parameter_27"></a>

|          |                                                                                                                                |
| -------- | ------------------------------------------------------------------------------------------------------------------------------ |
| message  | Text (message)                                                                                                                 |
| logLevel | Possible values are: InfoLogLevel.Info, InfoLogLevel.Message, InfoLogLevel.Warning, InfoLogLevel.ShowAlert, InfoLogLevel.Error |

#### Example <a href="#example_49" id="example_49"></a>

```csharp
//Tab protocol
Log("This is information.", InfoLogLevel.Info); //white
Log("This is a message.", InfoLogLevel.Message); // white
Log("This is a warning.", InfoLogLevel.Warning); // blue
Log("This is an alarm.", InfoLogLevel. ShowAlert); //green
Log("This is a mistake.", InfoLogLevel.Error); // red
//Tab messags
Log("This is a message (messages).", InfoLogLevel.Message); //white
//PopUp & protocoll
Log("This is an alert popup window.", InfoLogLevel.ShowAlert); //green

//Output-Tab:
//InfoLogLevel.Message = send to Tab "Messages" not "Log"

//Action:
/*
InfoLogLevel.Error: also the AT-Status-Line is red and flashes
InfoLogLevel.ShowAlert: opens also a modeless messagebox
*/

/*
Summary: * - InfoLogLevel.ShowAlert Color: green Tab: Log Action: modeless Messagebox * - InfoLogLevel.Warning Color: blue Tab: Log * - InfoLogLevel.Info Color: white Tab: Log * - InfoLogLevel.Error Color: red Tab: Log Action: AT-Status-Line: red + flashing (Error) * - InfoLogLevel.Message Color: white Tab: Messages
*/
```

Crossreference: a crossreference to Print() and ShowAlert()

### Occurred <a href="#occurred" id="occurred"></a>

#### Description <a href="#description_55" id="description_55"></a>

This DataSeries is used in conditions and indicates if signal occurred (1-long, -1 short, 0- no signal )

#### Parameter <a href="#parameter_28" id="parameter_28"></a>

None

#### Return value <a href="#return-value_16" id="return-value_16"></a>

Int

#### Usage <a href="#usage_41" id="usage_41"></a>

In scripted condition for short, long, none signal indication

#### Example <a href="#example_50" id="example_50"></a>

```csharp
protected override void OnCalculate()
{
if ( ProcessingBarIndex %2 == 0 )
Occurred.Set(1); // Long
else if ( ProcessingBarIndex %3 == 0 )
Occurred.Set(-1); // Short
else
Occurred.Set(0);
}
```

### OnBarsRequirements() <a href="#onbarsrequirements" id="onbarsrequirements"></a>

#### Description <a href="#description_56" id="description_56"></a>

The OnBarsRequirements() method is called up once at the beginning of an indicator and/or strategy calculation. This method is only necessary when using multi-bars. Within OnBarsRequirements, no other programming commands are executed. For initializing, the OnInit() or OnStart() method should be used.

#### Parameter <a href="#parameter_29" id="parameter_29"></a>

none

#### Return Value <a href="#return-value_17" id="return-value_17"></a>

none

#### Example <a href="#example_51" id="example_51"></a>

```csharp
protected override void OnBarsRequirements()
{
Add(DatafeedHistoryPeriodicity.Day, 1);
Add(DatafeedHistoryPeriodicity.Week, 1);
}
```

### OnInit() <a href="#oninit" id="oninit"></a>

#### Description <a href="#description_57" id="description_57"></a>

The OnInit() method is called up once at the beginning of an indicator or strategy calculation. This method can be used to set indicator properties, initialize your own variables, or add plots.

#### Parameter <a href="#parameter_30" id="parameter_30"></a>

none

#### Return Value <a href="#return-value_18" id="return-value_18"></a>

none

#### Usage <a href="#usage_42" id="usage_42"></a>

```csharp
protected override void OnInit()
```

#### Important Keywords <a href="#important-keywords" id="important-keywords"></a>

* [*Add()*](#addoutput)
* [*AllowRemovalOfChartDrawings*](#allowremovalofchartdrawings)
* *IsAutoScale*
* [*RequiredBarsCount*](#requiredbarscount)
* [*CalculateOnClosedBar*](#calculateonclosedbar)
* [*ClearTraceWindow()*](#cleartracewindow)
* [*Displacement*](#displacement)
* [*IsShowInDataBox*](#isshowindatabox)
* [*IsAddDrawingsToPricePanel*](#isadddrawingstopricepanel)
* [*InputPriceType*](#inputpricetype)
* [*IsOverlay*](#isoverlay)
* [*IsShowPriceMarkers*](#isshowpricemarkers)
* [*IsShowChartVerticalGrid*](#isshowchartverticalgrid)

**Additional Keywords for Strategies**

* [*DefaultOrderQuantity*](/strategy-programming.md#defaultorderquantity)
* *EntriesPerDirection*
* [*SetUpStopLoss()*](/strategy-programming.md#setupstoploss)
* [*SetUpProfitTarget()*](/strategy-programming.md#setupprofittarget)
* [*SetUpTrailStop()*](/strategy-programming.md#setuptrailstop)
* [*TimeInForce*](/strategy-programming.md#timeinforce)
* [*TraceOrders*](/strategy-programming.md#traceorders)

#### More Information <a href="#more-information_2" id="more-information_2"></a>

**Caution:** The OnInit() method is not only called up at the beginning of an indicator or strategy calculation, but also if the chart is reloaded unexpectedly or if the properties dialog of indicators is opened and so on. Developers of custom AgenaScripts should NOT use this method for running their own routines, opening forms, performing license checks, etc. The OnStart() method should be used for these kind of tasks.

#### Example <a href="#example_52" id="example_52"></a>

```csharp
protected override void OnInit()
{
AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Orange), "Output1"));
ClearTraceWindow();
IsAutoScale = false;
IsOverlay = true;
IsShowPriceMarkers = false;
IsShowInDataBox = false;
CalculateOnClosedBar = true;
}
```

### OutputDescriptor() <a href="#outputdescriptor" id="outputdescriptor"></a>

#### Description <a href="#description_58" id="description_58"></a>

A plot (drawing) is used to visually display indicators in a chart. OutputDescriptor objects are assigned to an indicator with the help of the Add() method and attached to the plots collection. See [*LevelLine*](#levelline).

#### Parameter <a href="#parameter_31" id="parameter_31"></a>

|                          |                                                                                                                                                                                                                                                                                                                            |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Color                    | Drawing color                                                                                                                                                                                                                                                                                                              |
| Pen                      | Pen object                                                                                                                                                                                                                                                                                                                 |
| OutputSeriesDisplayStyle | LevelLine type: OutputSeriesDisplayStyle.Bar, OutputSeriesDisplayStyle.Block, OutputSeriesDisplayStyle.Cross, OutputSeriesDisplayStyle.Dot, OutputSeriesDisplayStyle.Hash, OutputSeriesDisplayStyle.LevelLine, OutputSeriesDisplayStyle.Square, OutputSeriesDisplayStyle.TriangleDown, OutputSeriesDisplayStyle.TriangleUp |
| Name                     | Description                                                                                                                                                                                                                                                                                                                |

#### Usage <a href="#usage_43" id="usage_43"></a>

```csharp
OutputDescriptor(Color color, string name)
OnPOutputDescriptoraint(Pen pen, string name)
OutputDescriptor(Color color, OutputSeriesDisplayStyle plotStyle, string name)
OutputDescriptor(Pen pen, OutputSeriesDisplayStyle plotStyle, string name)
```

#### More Information <a href="#more-information_3" id="more-information_3"></a>

Information on the pen class: [*http://msdn.microsoft.com/de-de/library/system.drawing.pen.aspx*](http://msdn.microsoft.com/de-de/library/system.drawing.pen.aspx)

#### Example <a href="#example_53" id="example_53"></a>

```csharp
// Example 1
// OutputDescriptor with standard values (line with line strength 1)
AddOutput(new OutputDescriptor(Color.FromKnownColor(KnownColor.Orange), "Output1"));
// Example 2
// user-defined values for pen and plot style
private OutputDescriptor plot;
private Pen pen;
protected override void OnInit()
{
// a red pen with the line strength of 6 is defined
pen = new Pen(Color.Blue, 6);
// a point line with a thick red pen from above is defined
paint = new OutputDescriptor(pen, OutputSeriesDisplayStyle.Dot, "MyPlot");
// The defined plot is to be used as a representation for an indicator
Add(paint);
}
// Example 3
// Abbreviation of example 2
protected override void OnInit()
{
Add(new OutputDescriptor(new Pen(Color.Blue, 6), OutputSeriesDisplayStyle.Dot, "MyPlot"));
}
```

### InputParameter() <a href="#inputparameter" id="inputparameter"></a>

#### Description <a href="#description_59" id="description_59"></a>

Attribute which used for indicator customization

#### Return Value <a href="#return-value_19" id="return-value_19"></a>

None

#### Parameter <a href="#parameter_32" id="parameter_32"></a>

None

#### Example <a href="#example_54" id="example_54"></a>

```csharp
[Description("Period for the medium mean average")]
[InputParameter]
[DisplayName("MA Medium")]
public int MA_Medium
{
    get 
    { 
        return _ma_medium; 
    }
    set
    {
        _ma_medium = value;
    }
}
```

### PlaySound() <a href="#playsound" id="playsound"></a>

#### Description <a href="#description_60" id="description_60"></a>

This method allows you to play a wav file.

#### Usage <a href="#usage_44" id="usage_44"></a>

**PlaySound**(wavFile)

#### Return Value <a href="#return-value_20" id="return-value_20"></a>

none

#### Parameter <a href="#parameter_33" id="parameter_33"></a>

wavFile File name of the wav file to be played

#### Example <a href="#example_55" id="example_55"></a>

```csharp
using System.IO;
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string file = "\\\\AgenaTrader\\\\Sounds\\\\Alert1.wav";
PlaySound(path + file);
```

### PlotMethod <a href="#plotmethod" id="plotmethod"></a>

#### Description <a href="#description_61" id="description_61"></a>

In each indicator, the plot method can be overridden in order to add your own graphics (GDI+) to the price chart with the help of the graphics class (System.Drawing).

See [*http://msdn.microsoft.com/de-de/library/system.drawing.graphics.aspx*](http://msdn.microsoft.com/de-de/library/system.drawing.graphics.aspx).

The *Chart* object offers several parameters.

More examples: *Bar Numbering*, *PlotSample*, *Chart Background Image*.

#### Parameter <a href="#parameter_34" id="parameter_34"></a>

graphics The graphics object of the price chart (context)

rectangle The size of the drawing area (type "public struct rectangle")

double min The smallest price in the y-axis

double max The biggest price in the y-axis

#### Return Value <a href="#return-value_21" id="return-value_21"></a>

none

#### Usage <a href="#usage_45" id="usage_45"></a>

```csharp
public override void OutputDescriptor(Graphics graphics, Rectangle r, double min, double max)
```

#### Example <a href="#example_56" id="example_56"></a>

```csharp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using AgenaTrader.API;
using AgenaTrader.Custom;
using AgenaTrader.Plugins;
namespace AgenaTrader.UserCode
{
[Description("Example for the usage of the plot method.")]
public class PlotSample : UserIndicator
{
private StringFormat stringFormat = new StringFormat();
private SolidBrush brush = new SolidBrush(Color.Black);
private Font font = new Font("Arial", 10);
protected override void OnInit()
{
IsChartOnlyIndicator = true;
IsOverlay = true;
}
protected override void OnCalculate()
{}
protected override void OnDispose()
{
brush.Dispose();
stringFormat.Dispose();
}
public override void OutputDescriptor(Graphics graphics, Rectangle r, double min, double max)
{
// Fill a rectangle
SolidBrush tmpBrush = new SolidBrush(Color.LightGray);
graphics.FillRectangle(tmpBrush, new Rectangle (0, 0, 300, 300));
tmpBrush.Dispose();
// Draw a red line from top left to bottom right
Pen pen = new Pen(Color.Red);
graphics.AddChartLine(pen, r.X, r.Y, r.X + r.Width, r.Y + r.Height);
// Draw a red line from bottom left to top right
// Use anti-alias (the line appears smoother)
// The current settings for the smoothing are saved
// Restore after drawing
SmoothingMode oldSmoothingMode = graphics.SmoothingMode; //Save settings
graphics.SmoothingMode = SmoothingMode.AntiAlias; // Use higher smoothing settings
graphics.AddChartLine(pen, r.X, r.Y + r.Height, r.X + r.Width, r.Y);
graphics.SmoothingMode = oldSmoothingMode; // Settings restored
pen.Dispose();
// Text in the upper left corner (position 10,35)
stringFormat.Alignment = StringAlignment.Near; // Align text to the left
brush.Color = Color.Blue;
graphics.DrawString("Hello world!", font, brush, r.X + 10, r.Y + 35, stringFormat);
// Text in the left lower corner and draw a line around it
brush.Color = Color.Aquamarine;
graphics.FillRectangle(brush, r.X + 10, r.Y + r.Height - 20, 140, 19);
// Draw outside line
pen = new Pen(Color.Black);
graphics.AddChartRectangle(pen, r.X + 10, r.Y + r.Height - 20, 140, 19);
pen.Dispose();
// Write text
brush.Color = Color.Red;
graphics.DrawString("Here is bottom left!", font, brush, r.X + 10, r.Y + r.Height - 20, stringFormat);
}
}
}
```

### PriceType <a href="#pricetype" id="pricetype"></a>

#### Description <a href="#description_62" id="description_62"></a>

Price type describes a form of price data.

See [*InputPriceType*](#inputpricetype)

Following variables are available: - PriceType.Close - PriceType.High - PriceType.Low - PriceType.Median - PriceType.Open - PriceType.Typical - PriceType.Volume - PriceType.Weighted

#### Usage <a href="#usage_46" id="usage_46"></a>

PriceType

#### Example <a href="#example_57" id="example_57"></a>

See [*InputPriceType*](#inputpricetype)

### Print() <a href="#print" id="print"></a>

#### Description <a href="#description_63" id="description_63"></a>

The Print() method writes outputs in the AgenaTrader output window. See [*ClearTraceWindow()*](#cleartracewindow).

#### Usage <a href="#usage_47" id="usage_47"></a>

```csharp
Print(string message)
Print(bool value)
Print(double value)
Print(int value)
Print(DateTime value)
Print(string format, string message)
```

#### Parameter <a href="#parameter_35" id="parameter_35"></a>

string Text an individual message text

#### Return Value <a href="#return-value_22" id="return-value_22"></a>

none

#### More Information <a href="#more-information_4" id="more-information_4"></a>

Information regarding output formatting: *Formatting numbers*.

Hints about the String.Format() method: [*http://msdn.microsoft.com/de-de/library/fht0f5be%28v=vs.80%29.aspx*](http://msdn.microsoft.com/de-de/library/fht0f5be%28v=vs.80%29.aspx)

#### Example <a href="#example_58" id="example_58"></a>

```csharp
// "Quick&Dirty" formatting of a number with 2 decimal points
Print(Close[0].ToString("0.00"));
// Output day of the week from the timestamp for the bar
Print(string.Format("{0:dddd}", Time[0]));
// An additional empty row with an escape sequence
Print("One empty row afterwards \\n");
```

### ProcessingBarIndex <a href="#processingbarindex" id="processingbarindex"></a>

#### Description <a href="#description_64" id="description_64"></a>

Current bar is a method of indexing bars used in the OnCalculate() method. If a chart contains 500 bars and an indicator is to be calculated on the basis of these, then AgenaTrader will begin calculating from the oldest bar. The oldest bar receives the number 0. Once the calculation for this bar has been completed, the OnCalculate() method is called up for the next bar, which in turn receives the number 1. This continues until the last bar, which receives a value of 500.

#### Parameter <a href="#parameter_36" id="parameter_36"></a>

none

#### Return Value <a href="#return-value_23" id="return-value_23"></a>

Current bar is a variable of the type int, which always contains the number of the bar currently being used.

#### Usage <a href="#usage_48" id="usage_48"></a>

ProcessingBarIndex

#### More Information <a href="#more-information_5" id="more-information_5"></a>

The OnCalculate() method uses numbering different from that of ProcessingBarIndex in terms of the [*Barindex*](#processingbarindex) and [*Bars*](/handling-bars-and-instruments/bars.md). Understanding this difference is of great importance, which is why we ask you to please read the following paragraph carefully:

ProcessingBarIndex numbers continuously from the oldest to youngest bar starting with 0. The BarIndex for the youngest bar is always 0. In the example referenced below this paragraph, Time\[0] stands for the timestamp of the current bar. The index of the oldest bar always has 1 added to it. Thus a logical numbering of barsAgo is possible. The timestamp for the bar of 5 periods ago is Time\[5]. For using multiple timeframes (multi-bars) in an indicator, see ProcessingBarIndexes.

#### Example <a href="#example_59" id="example_59"></a>

```csharp
protected override void OnCalculate()
{
Print("Call of OnCalculate for bar nr. " + ProcessingBarIndex + " of " + Time[0]);
}
```

### RemoveChartDrawing() <a href="#removechartdrawing" id="removechartdrawing"></a>

#### Description <a href="#description_65" id="description_65"></a>

The RemoveChartDrawing() method removes a specific drawing object from the chart based on a unique identifier (tag). See [*RemoveChartDrawings()*](#removechartdrawings).

#### Usage <a href="#usage_49" id="usage_49"></a>

RemoveChartDrawings(string tag)

#### Return Value <a href="#return-value_24" id="return-value_24"></a>

none

#### Parameter <a href="#parameter_37" id="parameter_37"></a>

string tag The clearly identifiable name for the drawing object

#### Example <a href="#example_60" id="example_60"></a>

```csharp
RemoveChartDrawings("My line");
```

### RemoveChartDrawings() <a href="#removechartdrawings" id="removechartdrawings"></a>

#### Description <a href="#description_66" id="description_66"></a>

This method removes all drawings from the chart See [*RemoveChartDrawings()*](#removechartdrawings)*.*

#### Usage <a href="#usage_50" id="usage_50"></a>

RemoveChartDrawings()

#### Return Value <a href="#return-value_25" id="return-value_25"></a>

none

#### Example <a href="#example_61" id="example_61"></a>

```csharp
//Delete all drawings from the chart
RemoveChartDrawings();
```

### RequiredBarsCount <a href="#requiredbarscount" id="requiredbarscount"></a>

#### Description <a href="#description_67" id="description_67"></a>

The property "RequiredBarsCount" determines how many historical bars are required for an indicator or a strategy to call up the OnCalculate() method for the first time and thus begin the calculations. Bars required should be set within the OnInit() method. The setting should be chosen carefully. If you require 100 days for the calculation of a moving average, then you should ensure that at least 100 days of historical data are loaded. The property can be queried in the script and will return an int value.

When OnCalculate is called up for the first time, the ProcessingBarIndex property is 0 regardless of the value of RequiredBarsCount.

#### Usage <a href="#usage_51" id="usage_51"></a>

RequiredBarsCount

#### Example <a href="#example_62" id="example_62"></a>

```csharp
protected override void OnInit()
{
//The indicator requires a minimum of 50 bars loaded into the history
RequiredBarsCount = 50;
}
```

### ShowAlert() <a href="#showalert" id="showalert"></a>

#### Description <a href="#description_68" id="description_68"></a>

The ShowAlert method creates an acoustic and/or visual alarm.

#### Usage <a href="#usage_52" id="usage_52"></a>

```csharp
ShowAlert(string message, bool showMessageBox, string soundLocation);
//Due to compatability reasons, an old signature is still used here. When using this method, the color settings and the "re-arm seconds" parameter are ignored.
ShowAlert(string id, AlertPriority priority, string message, string soundLocation, int rearmSeconds, Color backColor, Color forColor);
```

#### Return Value <a href="#return-value_26" id="return-value_26"></a>

None

#### Parameter <a href="#parameter_38" id="parameter_38"></a>

|                |                                                                                                                    |
| -------------- | ------------------------------------------------------------------------------------------------------------------ |
| message        | Alert text displayed within the messages tab                                                                       |
| soundLocation  | Name of a sound file in the \*.wav format. If no path is specified, then "My Documents\AgenaTrader\Sounds\ is used |
| showMessageBox | If set to "true", a message box will be displayed in addition to the sound                                         |

#### Example <a href="#example_63" id="example_63"></a>

```csharp
// Message will be outputted if the SMA(20) crosses below the SMA(50)
if (CrossBelow(SMA(20), SMA(50), 1))
Alert("Check short signal!", true, "Alert4.wav");
```

To use music files in a different path, you need to specify the path:

```csharp
string pathOfSoundfile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)+@"\\MyAlertSounds\\";
string nameOfSoundFile = "MyAlertSoundFile.wav";
Alert("Message text", true, pathOfSoundfile + nameOfSoundFile);
```

### TickSize <a href="#ticksize" id="ticksize"></a>

A tick is the smallest possible price change of a financial instrument within an exchange. If, for example, the trading prices are specified to 2 decimal places, then a tick equals 0.01. You can expect Forex instruments to be specified to within 4 or 5 decimal places. A tick is called a pip in Forex trading and usually equals 0.0001 or 0.00001. The tick value is usually predefined by the exchange and does not (usually) change. See [*Instrument.TickSize*](/handling-bars-and-instruments/instruments.md#instrumentticksize).

Usually, a tick is displayed as a decimal number. Historically speaking (especially in American exchanges) stocks have been noted with tick sizes of 1/16 of a dollar. This notation is still widespread within commodities. Corn futures (ZC) are noted in ¼ US cents/bushel (usually equals 12.50 US$ per contract). US treasury bonds are noted in a tick size of 1/32 points, which equals 31.25$. Notations are usually made with apostrophes, for example:

149'00 equals exactly 149, 149'01 equals 149 1/32 (meaning 149.03125), 149'31 equals 149 31/32 (149.96875), and the next value after this is 150’00

In the so-called T-Bond intermonth spreads, notations are specified in quarters of 1/32, resulting in point values of 7.8125 per contract.

Notations have a dash:

17-24 equals 17 24/32 points, 17-242 equals 17 24.25/32 points, 17-245 equals 17 24.5/32 points and 17-247 equals 17 24.75/32 points. The next notation after 17-247 is 17-25 and then 17-252, 17-255 etc. After 17-317 comes 18.

The individual contract specifications can be found on the websites of the respective exchanges.

CME: [*http://www.cmegroup.com*](http://www.cmegroup.com/) under Products & Trading Eurex (FDAX): [*http://www.eurexchange.com/exchange-en/products/idx/dax/17206/*](http://www.eurexchange.com/exchange-en/products/idx/dax/17206/)

See [*Instrument.TickSize*](https://agenatrader.github.io/AgenaScript-documentation/keywords/#instrumentticksize).

### TimeFrame <a href="#timeframe" id="timeframe"></a>

See [*Bars.TimeFrame*](/handling-bars-and-instruments/bars.md#barstimeframe).

When using multiple timeframes ([*Multibars*](/handling-bars-and-instruments/multibars.md#multibars)) in an indicator, please see [*TimeFrames*.](#timeframe)

### Update() <a href="#update" id="update"></a>

#### Description <a href="#description_69" id="description_69"></a>

The Update() method calls up the OnCalculate method in order to recalculate the indicator values.

Update() is to be used with caution and is intended for use by experienced programmers.

#### Usage <a href="#usage_53" id="usage_53"></a>

```csharp
Update()
```

#### Return Value <a href="#return-value_27" id="return-value_27"></a>

none

#### Parameter <a href="#parameter_39" id="parameter_39"></a>

none

#### Example <a href="#example_64" id="example_64"></a>

The effect of update can be illustrated with the help of 2 indicators. The first indicator, Ind1, uses a public variable from the indicator Ind2.

**Code from Ind1:**

```csharp
public class Ind1 : UserIndicator
{
protected override void OnCalculate()
{
Print( Ind2().MyPublicVariable );
}
}
```

**Code from Ind2:**

```csharp
private double myPublicVariable = 0;
protected override void OnCalculate()
{
myPublicVariable = 1;
}
public double MyPublicVariable
{
get
{
Update();
return myPublicVariable;
}
}
```

**Without Update() - Wrong** If Ind2 is called up by Ind1, the get-method of MyPublicVariable is called up in Ind2. Without Update(), the value of MyPublicVariable would be returned. In this case it would be 0.

**With Update() - Correct** By calling up Update(), OnCalculate() is initially executed by Ind2. This sets MyPublicVariable to 1. Lastly, the value 1 is passed on to the requesting indicator.

### Value <a href="#value" id="value"></a>

#### Description <a href="#description_70" id="description_70"></a>

Value is a data series object containing the first data series of an indicator.

When the Add() method is called up, a value object is automatically created and added to the values collection.

Value is identical to Values\[0].

#### Usage <a href="#usage_54" id="usage_54"></a>

Value

Value\[**int** barsAgo]

#### More Information <a href="#more-information_6" id="more-information_6"></a>

The methods known for a collection, Set(), Reset(), and Count(), can be used for values.

#### Example <a href="#example_65" id="example_65"></a>

See [*Values*](#value).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://script.agenatrader.com/keywords.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
