> For the complete documentation index, see [llms.txt](https://script.agenatrader.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://script.agenatrader.com/handling-bars-and-instruments/bars.md).

# Bars

## Functionality&#x20;

A classical indicator calculates one or multiple values using an existing data series.

Data series can be anything from closing prices to daily lows or values of an hourly period etc.

Every period (meaning all candles of one day, one hour etc.) is assigned one or more indicator values. The following example is based on an indicator value, such as with a moving average, for example. To calculate a smoothed moving average, AgenaTrader needs a data series. In this example we will use the closing prices. All closing prices of a bar (candle) that are represented in the chart will be saved in a list and indexed.

The current closing price, meaning the closing price of the bar that is on the right-hand side of the chart, will be assigned an index of 0. The bar to the left of that will have an index of 1 and so on. The oldest bar displayed will have an index value of 500.

Whenever a new bar is added within a session it will become the new index 0; the bar to the left of it, which previously had an index of 0, will become index 1 and so on. The oldest bar will become index 501. Within a script (a self-created program/algorithm) the [*Close*](/handling-bars-and-instruments/data-series.md#close) will be representative for the array (list) of all closing prices. The last closing price is thus *Close \[0]*; the closing price previous to this will become *Close \[1]*, the value before that will become *Close \[2]* and the oldest bar will be *Close \[501]*. The number within the squared brackets represents the index. AgenaTrader allows you to use the „bars ago" expression for this in general cases.

Obviously, every bar will not only have a closing value but also a [*High*](/handling-bars-and-instruments/data-series.md#high), [*Low*](/handling-bars-and-instruments/data-series.md#low), [*Open*](/handling-bars-and-instruments/data-series.md#open), [*Median*](/handling-bars-and-instruments/data-series.md#median), [*Typical*](/handling-bars-and-instruments/data-series.md#typical), [*Weighted*](/handling-bars-and-instruments/data-series.md#weighted), [*Time*](/handling-bars-and-instruments/data-series.md#time) and [*Volume*](/handling-bars-and-instruments/data-series.md#volume). Thus, the high of the candle that occurred 10 days ago will be *High \[10]*, yesterday’s low *Low \[1]*...

**Important tip:**

The previous examples all assume that the calculations will occur at the end of a period. The value of the currently running index is not being taken into consideration.

If you wish to use the values of the currently forming candle then you will need to set the value of

*CalculateOnClosedBar* to „false".

In this case the currently running bar will have the value 0, the bar next to the current bar will have the value 1 and so on. The oldest bar (as in the example above) would now have the value 502.

With close \[0] you would receive the most recent value of the last price that your data provider transmitted to AgenaTrader. All values of the bar (high \[0], low \[0]…) may still change as long as the bar is not yet finished/closed and a new bar has not yet started. Only the open \[0] value will not change.

## Properties&#x20;

#### Properties of Bars <a href="#properties-of-bars" id="properties-of-bars"></a>

"Bars" represents a list of all bars (candles) within a chart (see [*Functionality*](#functionality), [*Bars*](/handling-bars-and-instruments/bars.md)).

Bars (**public** IBars Bars) can be used directly in a script and equates to BarsArray \[0] (see Bars.GetNextSessionTimeSpan for more information).

The list of bars itself has many properties that can be used in AgenaScript. Properties are always indicated by a dot before the objects (in this case bars, list of candles).

[*Bars.Count*](#bars.count)

[*Bars.CurrentSessionBeginTime*](#bars.currentsessionbegintime)

[*Bars.CurrentSessionEndTime*](#bars.currentsessionendtime)

[*Bars.GetBar*](#barsgetbar)

[*Bars.GetBarIndex*](#barsgetbarindex)

[*Bars.GetBarsAgo*](#barsgetbarsago)

[*Bars.GetByIndex*](#barsgetbyindex)

[*Bars.GetClose*](#barsgetclose)

[*Bars.GetHigh*](#barsgethigh)

[*Bars.GetLow*](#barsgetlow)

[*Bars.GetNextSessionTimeSpan*](#barsgetnextsessiontimespan)

[*Bars.GetOpen*](#barsgetopen)

[*Bars.GetSessionBegin*](#barsgetsessionbegin)

[*Bars.GetTime*](#barsgettime)

[*Bars.GetVolume*](#barsgetvolume)

[*Bars.Instrument*](#barsinstrument)

[*Bars.IsEod*](#barsiseod)

[*Bars.IsFalling*](#barsisfalling)

[*Bars.IsFirstBarInSession*](#barsisfirstbarinsession)

[*Bars.IsGrowing*](#barsisgrowing)

[*Bars.IsIntraday*](#barsisintraday)

[*Bars.IsNtb*](#barsisntb)

[*Bars.SessionBreak*](#barsissessionbreak)

[*Bars.LastBarCompleteness*](#barslastbarcompleteness)

[*Bars.NextSessionBeginTime*](#barsnextsessionbegintime)

[*Bars.NextSessionEndTime*](#barsnextsessionendtime)

[*Bars.TailBottom*](#barstailbottom)

[*Bars.TailTop*](#barstailtop)

[*Bars.TicksCountForLastBar*](#barstickscountforlastbar)

[*Bars.TicksCountInTotal*](#barstickscountintotal)

[*Bars.TimeFrame*](#barstimeframe)

[*BarsCountForSession*](#barscountforsession)

[*IsProcessingBarIndexLast*](#processingbarindexlast)

With the **OnCalculate()** method you can use any properties you want without having to test for a null reference. As soon as the function **OnCalculate()** is called up by AgenaScript, it is assumed that an object is also available. If you wish to use these properties outside of **OnCalculate()** then you should first perform a test for null references using **if** (Bars != **null**).

## Bars.Count&#x20;

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

Bars.Count gives you the amount of bars in a data series.

See [*Properties*](#properties) for additional information.

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

Type int Amount of Bars

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

Bars.Count

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

The value of *ProcessingBarIndex* can only be lesser than or equal to Bars.Count - 1

When you specify how many bars are to be loaded within AgenaTrader, then the value of Bars.Count is equal to this setting. In the following example, Bars.Count would give back a value of 500.

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2Fu6yiIY1iUGcfEmFPeZjm%2Fimage1.png?alt=media\&token=2b4725aa-2471-4ee8-be68-03b4f2c0740f)

#### Example

```csharp
Print ("There are a total of" + Bars.Count + "bars available.");
```

## Bars.CurrentSessionBeginTime

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

Bars.CurrentSessionBeginTime outputs the date and time for the beginning of the current trading session.

Date and time for the beginning of the current trading session will be displayed correctly when the function is used on a bar that has occurred in the past.

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

None

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

Type DateTime

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

Bars.GetSessionBegin

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

The time for the returned value will equal the starting time defined in the Market Escort for the specified exchange. The value itself is set within the Instrument Escort and can be called up in AgenaScript using the function [*Instrument.Exchange*](/handling-bars-and-instruments/instruments.md#instrumentexchange) .

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FyhWZkkNHnKfnki4etzLr%2FTradingHour_TSE.jpg?alt=media\&token=03a7b9e4-9c85-4640-9063-ff04fb3d77e2)

#### Exchange:

```csharp
Print("The currently running trading session started at " + Bars.CurrentSessionBeginTime );
```

## Bars.CurrentSessionEndTime

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

Bars.CurrentSessionEndTime outputs the time for the end of the currently running trading session. Date and time for the end of the current trading session will, in this case, also be outputted correctly when the function is used on a previous bar.

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

None

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

Type DateTime

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

Bars.GetSessionEnd

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

The time for the returned value will correlate with the end time of the trading session defined in the Market Escort for the exchange. The value itself can be set within the Instrument Escort and can be called up with AgenaScript using the [*Instrument.Exchange*](/handling-bars-and-instruments/instruments.md#instrumentexchange) function.

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2F6efYvTOcyH7FtmWYbWq0%2FTradingHour_Nashdaq.jpg?alt=media\&token=cb351cd6-c2bf-404d-8db7-5dd8e4c8597d)

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

```csharp
Print("The currently running trading session started at " + Bars.CurrentSessionBeginTime );
```

## Bars.GetBar <a href="#barsgetbar" id="barsgetbar"></a>

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

Bars.GetBar outputs the first bars (from oldest to newest) that correspond to the specified date/time.

See [*Bars.GetBarsAgo*](#barsgetbarsago), [*Bars.GetByIndex*](#barsgetbyindex), [*Bars.GetBarIndex*](#barsgetbarindex).

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

Type DateTime

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

Type IBar Bar Object, for the bars corresponding to the timestamp

For a timestamp older than the oldest bar: 0 (null) For a timestamp younger than the newest bar: index of the last bar

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

```csharp
Bars.GetBar(DateTime time)
```

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

For the indexing of bars please see [*Functionality*](#functionality), [*Bars*](/handling-bars-and-instruments/bars.md)

For more information about using DateTime see <http://msdn.microsoft.com/de-de/library/system.datetime.aspx>

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

```csharp
Print ("The closing price for 01.03.2012 at 18:00:00 was " + Bars.GetBar(new DateTime(2012, 01, 03, 18, 0, 0)).Close);
```

## Bars.GetBarIndex <a href="#barsgetbarindex" id="barsgetbarindex"></a>

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

Bars.GetBarIndex outputs the index of a bar – you can input either a bar object or a date-time object using this method.

See [*Bars.GetBar*](#barsgetbar), [*Bars.GetBarsAgo*](#barsgetbarsago), [*Bars.GetByIndex*](#barsgetbyindex).

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

Type IBar bar or Type DateTime

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

Type int The bar index of the specified bar object or DateTime object

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

```csharp
Bars.GetBarIndex (IBar bar)
Bars.GetBarIndex (DateTime dt)
```

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

For more information about indexing see [*Functionality*](#functionality), [*Bars*](/handling-bars-and-instruments/bars.md)

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

```csharp
int barsAgo = 5;
IBar bar = Bars.GetBar(Time[barsAgo]);
Print(barsAgo + " and " + Bars.GetBarIndex(bar) + " are equal in this example.");
```

## Bars.GetBarsAgo <a href="#barsgetbarsago" id="barsgetbarsago"></a>

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

Bars.GetBarsAgo outputs the index of the first bars (from oldest to newest) that correspond to the specified date/time.

See: [*Bars.GetBar*](#barsgetbar), [*Bars.GetBarsAgo*](#barsgetbarsago), [*Bars.GetByIndex*](#barsgetbyindex).

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

Type DateTime

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

Type int Index of the bar that corresponds to the timestamp

With a timestamp older than the oldest bar: 0 (null) With a timestamp newer than the youngest bar: index of the last bar

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

```csharp
Bars.GetBarsAgo(DateTime time)
```

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

For more information about indexing please see [*Functionality*](#functionality), [*Bars*](/handling-bars-and-instruments/bars.md)

For more information about using DateTime see <http://msdn.microsoft.com/de-de/library/system.datetime.aspx>

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

```csharp
Print("The bar for 01.03.2012 at 18:00:00 O’clock has an index of " + Bars.GetBarsAgo(new DateTime(2012, 01, 03, 18, 0, 0)));
```

## Bars.GetByIndex <a href="#barsgetbyindex" id="barsgetbyindex"></a>

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

Bars.GetByIndex outputs the index for the specified bar object

See [*Bars.GetBar*](#barsgetbar), [*Bars.GetBarsAgo*](#barsgetbarsago), [*Bars.GetByIndex*](#barsgetbyindex).

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

Type int Index

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

Type IBar Bar object for the specified index

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

```csharp
Bars.GetByIndex (int Index)
```

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

For indexing of bars see [*Functionality*](#functionality), [*Bars*](/handling-bars-and-instruments/bars.md)

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

```csharp
Print(Close[0] + " and " + Bars.GetByIndex(ProcessingBarIndex).Close + " are equal in this example.");
```

## Bars.GetClose <a href="#barsgetclose" id="barsgetclose"></a>

Bars.GetClose(int index) – see [*Bars.GetOpen*](#barsgetopen).

## Bars.GetHigh <a href="#barsgethigh" id="barsgethigh"></a>

Bars.GetHigh(int index) – see [*Bars.GetOpen*](#barsgetopen).

## Bars.GetLow <a href="#barsgetlow" id="barsgetlow"></a>

Bars.GetLow(int index) – see [*Bars.GetOpen*](#barsgetopen).

## Bars.GetNextSessionTimeSpan <a href="#barsgetnextsessiontimespan" id="barsgetnextsessiontimespan"></a>

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

Bars.GetNextSessionTimeSpan outputs the date and time for the beginning and end of a trading session.

See [*Bars.CurrentSessionBeginTime*](#bars.currentsessionbegintime), [*Bars.CurrentSessionEndTime*](#bars.currentsessionendtime), [*Bars.NextSessionBeginTime*](#barsnextsessionbegintime), [*Bars.NextSessionEndTime*](#barsnextsessionendtime).

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

|          |         |                                                                                            |
| -------- | ------- | ------------------------------------------------------------------------------------------ |
| DateTime | time    | Date or time for which the data of the following trading session will be scanned/searched. |
| iBars    | bars    | Bar object for which the data will be scanned/searched.                                    |
| int      | barsago | Number of days in the past for which the data will be searched/scanned.                    |

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

DateTime session begin DateTime session end

**Note:** The date for the beginning and the end of a trading session are connected components. If the specified date corresponds to the end date of the current trading session then the returned value for the beginning of a trading session may already be in the past. In this case the date for the following trading session cannot be returned.

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

```csharp
Bars.GetNextSessionTimeSpan(Bars bars, int barsAgo, out DateTime sessionBegin, out DateTime sessionEnd)
Bars.GetNextSessionTimeSpan(DateTime time, out DateTime sessionBegin, out DateTime sessionEnd)
```

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

The two signatures will not necessarily output the same result. When using the bar signature, the supplied bar will be inspected for its session template association. The beginning and end of the next session will be taken from this template.

When using the time signature, the date and time of the supplied bar will be used to calculate the data for the current and the following sessions.

When using the time signature, a timestamp is transmitted that corresponds exactly to the beginning or the end time of a session.

More information can be found here [*http://msdn.microsoft.com/de-de/library/system.datetime.aspx*](http://msdn.microsoft.com/de-de/library/system.datetime.aspx)

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

```csharp
DateTime sessionBegin;
DateTime sessionEnd;
protected override void OnCalculate()
{
Bars.GetNextSessionTimeSpan(Bars, 0, out sessionBegin, out sessionEnd);
Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd);
}
```

## Bars.GetOpen <a href="#barsgetopen" id="barsgetopen"></a>

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

For reasons of compatibility, the following methods are available.

* Bars.GetOpen(int index) outputs the open for the bars referenced with \<index>.
* Bars.GetHigh(int index) outputs the high for the bars referenced with \<index>.
* Bars.GetLow(int index) outputs the low for the bars referenced with \<index>.
* Bars.GetClose(int index) outputs the close for the bars referenced with \<index>.
* Bars.GetTime(int index) outputs the timestamp for the bars referenced with \<index>.
* Bars.GetVolume(int index) outputs the volume for the bars referenced with \<index>.

**Caution**: The indexing will deviate from the Indexing, *Bars* normally used. Here, the indexing will begin with 0 for the oldest bar (on the left of the chart) and end with the newest bar on the right of the chart (=Bars.Count-1).

The indexing can easily be recalculated:

```csharp
private int Convert(int idx)
{
return Math.Max(0,Bars.Count-idx-1-(CalculateOnClosedBar?1:0));
}
```

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

int index (0 .. Bars.Count-1)

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

Type double for GetOpen, GetHigh, GetLow, GetClose and GetVolume

Type DateTime for GetTime

## Bars.GetSessionBegin <a href="#barsgetsessionbegin" id="barsgetsessionbegin"></a>

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

Bars.GetSessionBegin provides the date and time of the particular session start. The date and time for the start of the current trading session are also correctly indicated when the function is called from a bar in the past. See also other [*Properties*](#properties) of bars.

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

None

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

Type DateTime

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

Bars.GetSessionBegin(DateTime dt)

#### Further Information <a href="#further-information" id="further-information"></a>

The time of the returned value corresponds to the start time of the trading session. The relevant trading center which is specified in the MarketEscort. The trading place used for the value is set in the Instrumet Escort and can be determined in AgenaSript with the Instrument.Exchange function.

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FyhWZkkNHnKfnki4etzLr%2FTradingHour_TSE.jpg?alt=media\&token=03a7b9e4-9c85-4640-9063-ff04fb3d77e2)

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

```csharp
Print("Die Handelssitzung am 25.03.2015 hat um "+ Bars.GetSessionBegin(new DateTime(2015, 03, 25)) + " begonnen.");
}
```

## Bars.GetTime <a href="#barsgettime" id="barsgettime"></a>

Bars.GetTime(int index) – see [*Bars.GetOpen*](#barsgetopen).

## Bars.GetVolume <a href="#barsgetvolume" id="barsgetvolume"></a>

Bars.GetVolume(int index) – see [*Bars.GetOpen*](#barsgetopen).

## Bars.Instrument <a href="#barsinstrument" id="barsinstrument"></a>

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

Bars.Instrument outputs an instrument object for the trading instrument displayed within the chart.

See [*Properties*](#properties) for more information.

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

None

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

Type Instrument

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

Bars.Instrument

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

For more information regarding the trading instruments please see [*Instruments*](/handling-bars-and-instruments/instruments.md).

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

```csharp
// both outputs will provide the same result
Print("The currently displayed trading instrument has the symbol: " + Bars.Instrument);
Instrument i = Bars.Instrument;
Print("The currently displayed trading instrument has the symbol " + i.Symbol);
```

## Bars.IsEod <a href="#barsiseod" id="barsiseod"></a>

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

Bars.IsEod can be used to check whether they are end-of-day bars.

See [*Properties*](#properties) for more information.

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

None

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

Type bool

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

Bars.IsEod

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

Within [*OnCalculate()*](/events.md#oncalculate), this property can be used without having to test for null reference. As soon as the method OnCalculate () is called by AgenaScript, there is always a bar object.

If this property used outside of OnCalculate (), then a corresponding test should be set to zero reference, e.g. With if (bars! = Null).

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

```csharp
Print("The bars are EOD: " + Bars.IsEod);
```

## Bars.IsFalling <a href="#barsisfalling" id="barsisfalling"></a>

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

Bar properties used when Bar is falling down.

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

None

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

None

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

```csharp
Bars[0].IsFalling;
```

## Bars.IsFirstBarInSession <a href="#barsisfirstbarinsession" id="barsisfirstbarinsession"></a>

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

With Bars.IsFirstBarInSession you can determine whether the current bar is the first bar of the trading session.

See [*Properties*](#properties) of bars for more information.

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

Type bool

**true**: The bar is the first bar of the current trading session **false**: The bar is not the first bar of the current trading session

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

Bars.IsFirstBarInSession

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

With [*OnCalculate()*](/events.md#oncalculate) this property can be used without having to test for a null reference. As soon as the OnCalculate() method is called up, an object will become available. If this property is called up outside of OnCalculate() you should test for a null reference using if (Bars != null).

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

```csharp
if (Bars.IsFirstBarInSession)
Print ("The current trading session started at" + Time [0]);
```

## Bars.isGrowing <a href="#barsisgrowing" id="barsisgrowing"></a>

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

Bar properties used when Bar is growing up.

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

None

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

None

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

```csharp
Bars[0].isGrowing;
```

## Bars.IsIntraday <a href="#barsisintraday" id="barsisintraday"></a>

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

Bars.IsIntraday returns a boolean which indicates if the TimeFrame is intra-day.

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

**bool**

It returns "true" if TimeFrame is intra-day (e.g. 1 min, 15 min, 1 hour, etc.) and "false" in other cases.

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

```csharp
Bars.IsIntraday
```

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

```csharp
if(Bars.IsIntraday) {
    Print("TimeFrame is Intraday.");
} else {
    Print("TimeFrame is not Intraday.");
}
```

## Bars.IsNtb <a href="#barsisntb" id="barsisntb"></a>

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

With Bars.IsNtb it can be checked whether it is not-time-based bars. For example Ntb bars are Point & Figure or Renko Charts.

See [*Properties*](#properties) for more information.

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

None

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

Type bool

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

Bars.IsNtb

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

[*OnCalculate()*](/events.md#oncalculate) property can be used without having to test for null reference first. As soon as the method OnCalculate() is called by AgenaScript, there is always a bar object. If this property is used outside of OnCalculate(), then a corresponding test should be set to zero reference, e.g. With if (bars! = Null).

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

```csharp
Print("The bars are Ntb: " + Bars.IsNtb);
```

### Bars.IsSessionBreak <a href="#barsissessionbreak" id="barsissessionbreak"></a>

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

Bars.IsSessionBreak can be used to determine whether the bars are within the commercial trading session in the commercial breaks defined in the marketplace escort.

See [*Properties*](#properties) for more information.

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

None

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

Type bool

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

Bars.IsSessionBreak

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

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2F6efYvTOcyH7FtmWYbWq0%2FTradingHour_Nashdaq.jpg?alt=media\&token=cb351cd6-c2bf-404d-8db7-5dd8e4c8597d)

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

```csharp
if (Bars.IsSessionBreak)
{
    Print("The stock exchange Xetra has just a trade pause.");
}
```

## Bars.LastBarCompleteness <a href="#barslastbarcompleteness" id="barslastbarcompleteness"></a>

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

Bars.LastBarCompleteness outputs the value that displays what percentage a bar has already completed. A bar with a period of 10 minutes has completed 50% after 5 minutes.

For non-time-based charts (Kagi, LineBreak, Renko, Range, P\&F etc.) this will output 0 during backtesting.

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

**double**

A percentage value; 30% will be outputted as 0.3

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

Bars.LastBarCompleteness

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

With [*OnCalculate()*](/events.md#oncalculate) this property can be used without having to test for a null reference. As soon as the OnCalculate() method is called up by AgenaScript, the object will become available.

If this property is used outside of OnCalculate() you should test for a null reference before executing it. You can test using *if* (Bars != *null*)

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

```csharp
// A 60 minute chart is looked at from an intraday perspective
// every 5 minutes before the current bar closes
// an acoustic signal shall be played
// 55 min. equals 92%
bool remind = false;
protected override void OnCalculate()
{
if (FirstTickOfBar) remind = true;
    if (remind && Bars.LastBarCompleteness >= 0.92)
    {
    remind = false;
    PlaySound("Alert1");
    }
}
```

## Bars.NextSessionBeginTime <a href="#barsnextsessionbegintime" id="barsnextsessionbegintime"></a>

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

Bars.NextSessionBeginTime outputs the date and time for the start of the next trading session. Date and time for the next session will be correctly outputted when the function is used on a bar in the past.

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

None

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

Type DateTime

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

Bars.GetSessionNextBegin

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

The time for the returned value will correlate to the value displayed in the MarketEscort. The value can be set within the Instrument Escort and can be called up using the [*Instrument.Exchange*](/handling-bars-and-instruments/instruments.md#instrumentexchange) function.

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FyhWZkkNHnKfnki4etzLr%2FTradingHour_TSE.jpg?alt=media\&token=03a7b9e4-9c85-4640-9063-ff04fb3d77e2)

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

```csharp
Print("The next trading session starts at " + Bars.NextSessionBeginTime);
```

## Bars.NextSessionEndTime <a href="#barsnextsessionendtime" id="barsnextsessionendtime"></a>

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

Bars.NextSessionEndTime outputs the date and time for the end of the next session. See [*Properties*](#properties) for more information.

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

None

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

Type DateTime

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

Bars.GetSessionNextEnd

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

The time for the returned value will correlate with the value specified within the MarketEscort. The value itself can be set within the Instrument Escort and can be called up with AgenaScript using the [*Instrument.Exchange*](/handling-bars-and-instruments/instruments.md#instrumentexchange) function.

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2F6efYvTOcyH7FtmWYbWq0%2FTradingHour_Nashdaq.jpg?alt=media\&token=cb351cd6-c2bf-404d-8db7-5dd8e4c8597d)

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

```csharp
Print("The next trading session ends at " + Bars.NextSessionEndTime);
```

## Bars.TailBottom <a href="#barstailbottom" id="barstailbottom"></a>

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

With this property you are able to get the height of the bottom candle tail.

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

None

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

None

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

```csharp
Bars[0].TailBottom;
```

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

```csharp
Print("The height of the bottom candle tail is: " + Bars.TailBottom);
```

## Bars.TailTop <a href="#barstailtop" id="barstailtop"></a>

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

With this property you are able to get the height of the top candle tail.

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

None

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

None

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

```csharp
Bars[0].TailTop;
```

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

```csharp
Print("The height of the top candle tail is: " + Bars.TailTop);
```

## Bars.TicksCountForLastBar <a href="#barstickscountforlastbar" id="barstickscountforlastbar"></a>

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

Bars.TicksCountForLastBar outputs the total numbers of ticks contained within a bar.

More information can be found in [*Properties*](#properties) of bars.

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

None

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

Type int

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

Bars.TicksCountForLastBar

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

With [*OnCalculate()*](/events.md#oncalculate) this property can be used without having to test for a null reference. As soon as the OnCalculate() method is called up by AgenaScript, the object will become available.

If this property is used outside of OnCalculate(), you should test for a null reference before executing it. You can test using *if* (Bars != *null*)

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

```csharp
Print("The current bar consists of " + Bars.TicksCountForLastBar + " Ticks.");
```

## Bars.TicksCountInTotal <a href="#barstickscountintotal" id="barstickscountintotal"></a>

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

Bars.TicksCountInTotal outputs the total number of ticks from the moment the function is called up.

More information can be found here: [*Properties*](#properties).

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

None

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

Type int

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

Bars.TicksCountInTotal

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

The data type int has a positive value range of 2147483647. When you assume 10 ticks per second, there will be no overlaps within 2 trading months with a daily runtime of 24 hours.

With [*OnCalculate()*](/events.md#oncalculate) this property can be used without having to test for a null reference. As soon as the OnCalculate() method is called up by AgenaScript, the object will become available.

If this property is used outside of OnCalculate(), you should test for a null reference before executing it. You can test using *if* (Bars != *null*)

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

```csharp
Print("The total amount of ticks is " + Bars.TicksCountInTotal);
```

## Bars.TimeFrame <a href="#barstimeframe" id="barstimeframe"></a>

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

Bars.TimeFrame outputs the timeframe object containing information regarding the currently used timeframe.

More information can be found here: [*Properties*](#properties)

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

None

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

Type ITimeFrame

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

Bars.TimeFrame

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

For more information about timeframe objects please see [*TimeFrame*](/handling-bars-and-instruments/data-series.md#timeframe).

With [*OnCalculate()*](/events.md#oncalculate) this property can be used without having to test for a null reference. As soon as the OnCalculate() method is called up by AgenaScript, the object will become available.

If this property is used outside of OnCalculate(),you should test for a null reference before executing it. You can test using *if* (Bars != *null*)

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

```csharp
//Usage within a 30 minute chart
TimeFrame tf = (TimeFrame) Bars.TimeFrame;
Print(Bars.TimeFrame); // outputs "30 Min"
Print(tf.Periodicity); // outputs "Minute"
Print(tf.PeriodicityValue); // outputs "30"
```

## BarsCountForSession <a href="#barscountforsession" id="barscountforsession"></a>

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

Bars.BarsCountForSession outputs the amount of bars that have occurred since the beginning of the current trading session.

See further [*Properties*](#properties) of bars.

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

Type int Amount of Bars

A value of -1 indicates a problem with referencing the correct session beginning.

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

Bars.BarsCountForSession

#### Further Information <a href="#further-information_1" id="further-information_1"></a>

Within *OnCalculate()* this property can be used without having to test for a null reference. As soon as the OnCalculate() method is called up by AgenaScript, the object will become available.

If this property is used outside of OnCalculate() then you should test for a null reference before executing it. You can test using *if* (Bars!= *null*) .

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

```csharp
Print("Since the start of the last trading session there have been" + Bars.BarsCountForSession + "bars.");
```

## ProcessingBarIndexLast <a href="#processingbarindexlast" id="processingbarindexlast"></a>

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

Indicates if current bar is last in calculation.

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

none

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

Type bool

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

ProcessingBarIndexLast

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

used for complicated calculation on a last bar

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

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