AgenaScript
HomeIndicatorsAgenaScriptRelease Notes
  • 🖥️AgenaScript - Let's start
    • Introductory Words
  • Handling bars and instruments
    • Bars
    • Collections
    • Data Series
    • Instruments
    • Multibars
  • Events
  • Strategy Programming
  • Keywords
  • DrawingObjects
  • TradersYard Social Trading
  • Hints & Advice
Powered by GitBook
On this page
  • Open
  • Opens
  • High
  • Highs
  • Low
  • Lows
  • Close
  • Closes
  • Median
  • Medians
  • Typical
  • Typicals
  • Weighted
  • Weighted
  • Weighteds
  • Time
  • Times
  • Volume
  • Volumes
  • TimeFrame
  • TimeFrames
Edit on GitLab
  1. Handling bars and instruments

Data Series

Last updated 1 year ago

Data series are interpreted as freely usable data storage containers for your programs. Additionally, they an integrated component of AgenaTrader that saves the price changes for individual bars. We will be focusing on the latter function here. In the following section, the concept of data series will be explained in detail and understandably. All price data for the individual bars are organized and saved within data series. The following are available:

Open

Description

Open is a of the type , in which the historical opening prices are saved.

Parameter

BarsAgo Index Value (see )

Usage

Open
Open[int barsAgo]

More Information

Example

// Opening price for the current period
Print(Time[0] + " " + Open[0]);
// Opening price for the bars of 5 periods ago
Print(Time[5] + " " + Open[5]);
// Current value for the SMA 14 that is based on the opening prices (rounded)
Print("SMA(14) calculated using the opening prices: " + Instrument.Round2TickSize(SMA(Open, 14)[0]));

Opens

Description

Opens is an array of data series that contains all open data series.

This array is only useful or meaningful for indicators or strategies that use multiple data from multiple timeframes. A new entry is entered into the array whenever a new timeframe is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Opens[0] The open data series of the chart timeframe Opens[1] The open data series of all bars in a daily timeframe Opens[2] The open data series of all bars in a weekly timeframe

Opens[0][0] is equivalent to Open[0].

Parameter

Usage

Opens[int barSeriesIndex]
Opens[int barSeriesIndex][int barsAgo]

More Information

Example

High

Description

Parameter

Usage

High
High[int barsAgo]

More Information

Example

// High values of the current period
Print(Time[0] + " " + High[0]);
// High values of the bar from 5 periods ago
Print(Time[5] + " " + High[5]);
// the current value for the SMA 14 calculated on the basis of the high prices
Print("SMA(14) Calculated using the high prices: " + Instrument.Round2TickSize(SMA(High, 14)[0]));

Highs

Description

Highs is an array of [DataSeries][1] that contains all high data series.

This array is only of value for indicators or strategies that use data from multiple timeframes.

A new entry is added to the array whenever a new time unit is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Highs[0] the high data series of the chart timeframe Highs[1] the high data series of all bars in a daily timeframe Highs[2] the high data series of all bars in a weekly timeframe

Highs[0][0] is equivalent to High[0].

Parameter

Usage

Highs[int barSeriesIndex]
Highs[int barSeriesIndex][int barsAgo]

More Information

Example

Low

Description

Parameter

Usage

Low
Low[int barsAgo]

More Information

Example

// Lowest value of the current period
Print(Time[0] + " " + Low[0]);
// Lowest value of the bar from 5 periods ago
Print(Time[5] + " " + Low[5]);
// The current value for the SMA 14 calculated on the basis of the low prices (smoothed)
Print("SMA(14) calculated using the high prices: " + Instrument.Round2TickSize(SMA(Low, 14)[0]));

Lows

Description

This array is only of value to indicators or strategies that use data from multiple time units.

A new entry is added whenever a new time unit is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Lows[0] the low data series for the chart timeframe Lows[1] the low data series for all bars in a daily timeframe Lows[2] the low data series for all bars in a weekly timeframe

Lows[0][0] is equivalent to Low[0].

Parameter

barsAgo Index value for the individual bars within the data series barSeriesIndex Index value for the various timeframes

Usage

Lows[int barSeriesIndex]
Lows[int barSeriesIndex][int barsAgo]

More Information

Example

Close

Description

Parameter

Usage

Close
Close[int barsAgo]

More Information

Indicators are usually calculated using the closing prices.

Example

// Closing price of the current period
Print(Time[0] + " " + Close[0]);
// Closing price of the bar from 5 periods ago
Print(Time[5] + " " + Close[5]);
// Current value for the SMA 14 based on the closing prices
Print("SMA(14) calculated using the closing prices: " + Instrument.Round2TickSize(SMA(Close, 14)[0]));
// Close does not need to be mentioned since it is used by default
Print("SMA(14) calculated using the closing prices: " + Instrument.Round2TickSize(SMA(14)[0]));

Closes

Description

This array is only of importance to indicators or strategies that use data from multiple time units.

A new entry is added to the array whenever a timeframe is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Closes[0] the close data series of the chart timeframe Closes[1] the close data series of all bars in a daily timeframe Closes[2] the close data series of all bars in a weekly timeframe

Closes[0][0] is equivalent to Close[0].

Parameter

barsAgo Index value of the individual bars within the data series barSeriesIndex Index value for the various timeframes

Usage

Closes[int barSeriesIndex]
Closes[int barSeriesIndex][int barsAgo]

More Information

Example

Median

Description

The median price of a bar is calculated using (high + low) / 2

Parameter

Usage

Median
Median[int barsAgo]

More Information

Example

// Median price for the current period
Print(Time[0] + " " + Median[0]);
// Median price of the bar from 5 periods ago
Print(Time[5] + " " + Median[5]);
// Current value for the SMA 14 calculated using the median prices
Print("SMA(14) calculated using the median prices: " + Instrument.Round2TickSize(SMA(Median, 14)[0]));

Medians

Description

This array is only of value to indicators or strategies that use data from multiple timeframes.

A new entry is added to the array whenever a new time frame is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Medians[0] the median data series of the chart timeframe Medians[1] the median data series of all bars in a daily timeframe Medians[2] the median data series of all bars in a weekly timeframe

Medians[0][0] is equivalent to Medians[0].

Parameter

barsAgo Index value for the individual bars within a data series barSeriesIndex Index value for the various timeframes

Usage

Medians[int barSeriesIndex]
Medians[int barSeriesIndex][int barsAgo]

More Information

Example

Typical

Description

The typical price of a bar is calculated using (high + low + close) / 3.

Parameter

Usage

Typical
Typical[int barsAgo]

More Information

Example

// Typical price for the current period
Print(Time[0] + " " + Typical[0]);
// Typical price of the bar from 5 periods ago
Print(Time[5] + " " + Typical[5]);
// Current value for the SMA 14 calculated using the typical price
Print("SMA(14) calculated using the typical price: " + Instrument.Round2TickSize(SMA(Typical, 14)[0]));

Typicals

Description

This array is only of value to indicators and strategies that make use of multiple timeframes.

A new entry is added to the array whenever a new timeframe is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Typicals[0] the typical data series of the chart timeframe Typicals[1] the typical data series of all bars in a daily timeframe Typicals[2] the typical data series of all bars in a weekly timeframe

Typicals[0][0] is equivalent to Typicals[0].

Parameter

barsAgo Index value of the individual bars within a data series barSeriesIndex Index value of the various timeframes

Usage

Typicals[int barSeriesIndex]
Typicals[int barSeriesIndex][int barsAgo]

More Information

Example

Weighted

Description

The weighted price of a bar is calculated using the formula (high + low + 2*close) / 4 and then weighted on the closing price.

Parameter

Usage

Weighted

Weighted[int barsAgo]

More Information

Example

// Weighted price for the current period
Print(Time[0] + " " + Weighted[0]);
// Weighted price of the bar from 5 periods ago
Print(Time[5] + " " + Weighted[5]);
// Current value for the SMA 14 using the weighted price
Print("SMA(14) calculated using the weighted price: " + Instrument.Round2TickSize(SMA(Weighted, 14)[0]));

Weighteds

Description

The array is only of value for indicators and strategies that use data from multiple timeframes.

A new entry is added to the array whenever a new timeframe is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Weighteds[0] the weighted data series of the chart timeframe Weighteds[1] the weighted data series of all bars in a daily timeframe Weighteds[2] the weighted data series of all bars in a weekly timeframe

Weighteds[0][0] is equivalent to Weighteds[0].

Parameter

barsAgo Index value of the individual bars within a data series barSeriesIndex Index value for the various timeframes

Usage

Weighteds[int barSeriesIndex]
Weighteds[int barSeriesIndex][int barsAgo]

More Information

Example

Time

Description

Parameter

Usage

Time
Time[int barsAgo]

More Information

Example

// Timestamp of the current period
Print(Time[0]);
// Timestamp of the bar from 5 periods ago
Print(Time[5]);

Times

Description

This array is only of value to indicators and strategies that make use of multiple timeframes. A new entry is added to the array whenever a new timeframe is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Times[0] the time data series of the chart timeframe Times[1] the time data series of all bars in a daily timeframe Times[2] the time data series of all bars in a weekly timeframe

Times[0][0] is equivalent to Times[0].

Parameter

barsAgo Index value for the individual bars within a data series barSeriesIndex Index value for the various timeframes

Usage

Times[int barSeriesIndex]
Times[int barSeriesIndex][int barsAgo]

More Information

Example

Volume

Description

Parameter

Usage

Volume

Volume[int barsAgo]

More Information

The value returned by the VOL() indicator is identical with the volume described here; for example, Vol()[3] will have the same value as Volume[3].

Example

// Volume for the current period
Print(Time[0] + " " + Volume[0]);
// Volume of the bar from 5 periods ago
Print(Time[5] + " " + Volume[5]);
// Current value for the SMA 14 calculated using the volume
Print("SMA(14) calculated using the volume: " + Instrument.Round2TickSize(SMA(Volume, 14)[0]));

Volumes

Description

This array is only of value for indicators or strategies that use data from multiple timeframes.

A new entry is added to the array whenever a new timeframe is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

Volumes[0] the volume data series of the chart timeframe Volumes[1] the volume data series of all bars in the daily timeframe Volumes[2] the volume data series of all bars in the weekly timeframe

Volumes[0][0] is equivalent to Volumes[0].

Parameter

barsAgo Index value of the individual bars within a data series

barSeriesIndex Index value of the various timeframes

Usage

Volumes[int barSeriesIndex]
Volumes[int barSeriesIndex][int barsAgo]

More Information

Example

TimeFrame

Description

TimeFrame is a timeframe object. This property is used to read the current TimeFrame and not to set it.

Usage

TimeFrame

TimeFrames

Description

TimeFrames is an array of timeframe objects that contains a timeframe object for each individual bar object.

This array is only of value for indicators or strategies that use data from multiple timeframes.

A new entry is added to the array whenever a new timeframe is added to an indicator or strategy.

With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:

TimeFrames [0] Timeframe of the primary data series (chart timeframe) TimeFrames [1] Print(TimeFrames[1]); // returns "1 Day" TimeFrames [2] Print(TimeFrames[2]); // returns "1 Week"

Parameter

barSeriesIndex Index value for the various timeframes

Usage

TimeFrames [int barSeriesIndex]

Example

if (ProcessingBarSeriesIndex == 0 && ProcessingBarIndex == 0)
for (int i = BarsArray.Count-1; i >= 0; i--)
Print("The Indicator " + this.Name + " uses Bars of the Timeframe " + TimeFrames[i]);

The returned value is dependent upon the property of .

In addition, please see for more information.

barsAgo Index value for the individual bars within the data series (see ) barSeriesIndex Index value for the various timeframes

The returned value is dependent upon the property of .

See example: .

High is a of the type , in which the historical high prices are saved.

barsAgo IndexValue (see )

The returned value is dependent upon the property of .

See .

barsAgo Index value for the individual bars within the data series (see ) barSeriesIndex Index value for the various timeframes

The returned value is dependent upon the property of .

Please see examples under .

Low is a of the type , in which the historical low prices are saved.

barsAgo IndexValue (see )

The returned value is dependent upon the property of .

Lows is an array of [DataSeries][1] that contains all data series.

See .

The returned value is dependent upon the property .

See example .

Close is a of the type , in which the historical closing prices are saved.

barsAgo Index value (see )

The returned value is dependent upon the property .

Closes is an array of [DataSeries][1] that contains all data series.

See .

The returned value is dependent upon the property .

See example .

Median is a of the type , in which the historical median values are saved.

See & .

barsAgo Index value (see )

The returned value is dependent upon the property .

Further information about median, typical und weighted:

Medians is an array of [DataSeries][1] that contains all data series.

See .

The returned value is dependent upon the property .

Further information on median:

See example in .

Typical is a of the type , in which the historical typical values are saved.

See and .

barsAgo Index value (see )

The returned value is dependent upon the property .

Further information on typical:

Typicals is an array of DataSeries that contains all data series.

See .

The returned value is dependent upon the property .

See example .

Weighted is a of the type , in which the historical weighted values are saved.

See also and .

barsAgo Index value (see )

The returned value is dependent upon the property .

Information regarding weighted:

Weighteds is an array of [DataSeries][1] that contains all data series.

See .

The returned value is dependent upon the property .

See example under .

Time is a of the type , in which the timestamps of the individual bars are saved.

barsAgo Index value (see )

The returned value is dependent upon the property .

Times is an array of that contains all data series.

See .

The returned value is dependent upon the property .

See example .

Volume is a of the type , in which the historical volume information is saved.

barsAgo Index value (see )

The returned value is dependent upon the property .

Volumes is an array of that contains all data series.

See .

The returned value is dependent upon the property

See example .

TimeFrames [0] is equivalent to .

See .

MultiBars
Bars
Multibars
Data Series
Data Series
Bars
MultiBars
Bars
Multibars
DataSeries
DataSeries
Bars
MultiBars
Multibars
DataSeries
DataSeries
Bars
MultiBars
Multibars
DataSeries
DataSeries
Bars
http://blog.nobletrading.com/2009/12/median-price-typical-price-weighted.html
MultiBars
http://www.investopedia.com/terms/m/median.asp
Multibars
DataSeries
DataSeries
Bars
https://technicianapp.com/resources/typical-price/
MultiBars
Multibars
DataSeries
DataSeries
Bars
http://www.stock-trading-infocentre.com/pivot-points.html
MultiBars
Multibars
Bars
MultiBars
Multibars
DataSeries
DataSeries
Bars
CalculateOnClosedBar
MultiBars
Multibars
MultiBars
DataSeries
DataSeries
Bars
Open
High
Low
Close
Median
Typical
Weighted
Time
TimeFrame
Volume
Low
Low
Typical
Weighted
Median
Median
Weighted
Typical
Median
Typical
Weighted
DataSeries
Time
DataSeries
Volume
TimeFrame
DataSeries
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar
DateTimeSeries
CalculateOnClosedBar
CalculateOnClosedBar
CalculateOnClosedBar.