Keywords
AddOutput()
AddLine()
Description
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
plot – a OutputDescriptor object line – a LevelLine object
Usage
Example
AllowRemovalOfChartDrawings
Description
"AllowRemovalOfChartDrawings" is a property of indicators that can be set under 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
Example
Attribute
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 is an 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.
Example for a data series:
Category
Category is an 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:
If you use the category 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":
ConditionalValue
Conditional value is an 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.
Description
Description is an 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.
The descriptions are displayed in the relevant properties dialog.
DisplayName
Display name is an 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.
TimeFrameRequirements
Timeframe requirements is an 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:
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.
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
XML ignore is an 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.
CalculateOnClosedBar
Description
The property "CalculateOnClosedBar" determines the events for which AgenaTrader can call up the OnCalculate() method.
OnCalculate() is called up when a bar is closed and the next incoming tick creates a new bar.
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
CalculateOnClosedBar
More Information
See Bars.
Example
Chart
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.
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()
Description
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() command. Using the output window is a great method for code debugging.
Usage
Parameter
none
Return Value
none
Example
Colors
AgenaScript provides you with the following commands for defining colors and making color changes to the chart:
BarColor Color of a bar
BackColor Background color of the chart
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.
BackColor
Description
Back color changes the background color of a bar or gives the current background color of a bar when queried.
See Colors, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
A color object of the type "public struct color"
Usage
BackColor
Example
BackColorAll
Description
Back color all changes the background color of a bar within the chart window and in all subcharts.
See Colors, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
A color object of the type "public struct color"
Usage
BackColorAll
Example
BackColorAllSeries
Description
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, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
a color object of the type "public struct color"
int barsAgo
Usage
When using the method with an index [int barsAgo] the background color for the referenced bar will be changed or returned.
Example
See BackColorSeries.
BackColorSeries
Description
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, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
a color object of the type "public struct color"
int barsAgo
Usage
When using this method with an index [int barsAgo] the background color for the referenced bar will be outputted.
Example
BarColor
Description
Bar color changes the color of a bar.
See Colors, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
a color object of the type "public struct color"
Usage
BarColor
Example
BarColorSeries
Description
Bar color series is a data series containing the color for each bar.
See Colors, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
a color object of the type "public struct color"
int barsAgo
Usage
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
CandleOutlineColor
Description
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, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
a color object of the type "public struct color"
Usage
CandleOutlineColor
Example
CandleOutlineColorSeries
Description
Candle outline color series is a data series that saves the outline color for each bar.
See Colors, BarColor, BackColor, BackColorAll, BarColorSeries, BackColorAll, CandleOutlineColor.
Parameter
a color object of the type "public struct color"
int barsAgo
Usage
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
CrossAbove()
Description
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(), CrossBelow(), IsSerieRising(), IsSerieFalling().
Usage
Return Value
true a cross has occurred false a cross has not occurred
Parameter
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
CrossBelow()
Description
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(), CrossBelow(), IsSerieRising(), IsSerieFalling().
Usage
Return Value
true a cross has occurred false a cross has not occurred
Parameter
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
DatafeedHistoryPeriodicity
Description
Datafeed history periodicity is a data type.
Definition
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
Description
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.
Usable Data Series in AgenaTrader
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.
Set(), Reset() und ContainsValue()
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
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types
BoolSeries
Description
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
In the area for the declaration of variables, simply declare a new variable:
With the OnInit() method, this variable assigns a new instance of the Bool series:
Assign Values
Assigning a value to the data series for the current position:
Writing a value in the past into the data series:
Delete Values
Removing the current value for the data series:
Removing a value in the past from the data series:
Check Values for their Validity
Read Value
Example
DataSeries
Description
Data series is a 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
In the declaration area for variables:
With the OnInit() method, this variable is assigned a new instance:
Assign Values
Assigning a value to the data series for the current position:
Writing a value in the past into the data series:
Delete Values
Removing the current value from the data series:
Removing a value in the past from the data series:
Check Values for their Validity
Read Value
Example
DateTimeSeries
Description
Date time series is a 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
Create a new variable in the declaration area:
Assign a new instance of DateTimeSeries for the variable with the OnInit() method:
Assign Values
Assigning a value to the current position of the data series:
Writing a value from the past into the data series:
Delete Values
Removing the current value from the data series:
Remove a past value from the data series:
Check Values for their Validity
Read Value
Example
FloatSeries
Description
Float series is a 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
Create a new variable in the declaration area:
Assign a new instance of the FloatSeries to the variable with the OnInit() method:
Assign Values
Assigning a value to the current position of the data series
Writing a value from the past into the data series:
Delete Values
Removing the current value from the data series:
Removing a value located in the past from the data series:
Check Values for their Validity
Read Value
Example
IntSeries
Description
Int series is a 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
Create a new variable in the declaration area:
Assign an instance of the int series to the variable with the OnInit() method:
Assign Values
Assigning a value to the current position of the data series
Writing a value from the past into the data series:
Delete Values
Removing the current value from the data series:
Removing a value located in the past from the data series:
Check Values for their Validity
Read Value
Example
LongSeries
Description
Long series is a 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
Create a new variable in the declaration area:
Assign a new instance of the long series to the variable with the OnInit() method:
Assign Values
Assigning a value to the current position of the data series:
Writing a value from the past into the data deries:
Delete Values
Removing the current value from the data series:
Removing a value located in the past from the data series:
Check Values for their Validity
Read Value
Example
StringSeries
Description
String series is a 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
Create a new variable in the declaration area:
Assign an instance of string series to the variable with the OnInit() method:
Assign Values
Assigning a value to the current position of the data series:
Writing a value from the past into the data series:
Delete Values
Remove the current value from the data series:
Remove a value located in the past from the data series:
Check Values for their Validity
Read Value
Example
DayOfWeek
Description
"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
Property DayOfWeek
public enum DayOfWeek - DayOfWeek.Monday - DayOfWeek.Tuesday - DayOfWeek.Wednesday - DayOfWeek.Thursday - DayOfWeek.Friday - DayOfWeek.Saturday - DayOfWeek.Sunday
Example
Displacement
Description
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
Usage
Displacement
Parameter
int Offset Number of bars by which the indicator is to be moved.
Example
Email function
Description
Override method which allows to send mail.
Parameter
None
Return value
string
Usage
used for complicated calculation on a last bar
Example
FirstTickOfBar
Description
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.
Usage
FirstTickOfBar
Example
FirstTickOfBarMtf
Description
FirstTickOfBarMtf is the multi-time frame variant of the 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
FirstTickOfBarMtf(ProcessingBarSeriesIndex)
Parameter
FirstTickOfBarMtf(ProcessingBarSeriesIndex).
Example
GetCurrentAsk()
Description
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() and OnLevel1().
Usage
GetCurrentAsk()
Return Value
double value
Parameter
none
Example
GetCurrentAskVolume()
Description
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(), GetCurrentBid() and OnLevel1().
Usage
GetCurrentAskVolume()
Return Value
Long value
Parameter
none
Example
GetCurrentBid()
Description
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() and OnLevel1().
Usage
GetCurrentBid()
Return Value
double value
Parameter
none
Example
If an entry condition is fulfilled, then 1 contract should be sold at the current bid price:
GetCurrentBidVolume()
Description
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, GetCurrentBid() and OnLevel1().
Usage
GetCurrentBidVolume()
Return Value
Long value
Parameter
none
Example
GetCurrentPrice()
Description
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, GetCurrentBid() and OnLevel1().
Usage
GetCurrentPrice()
Return Value
none
Parameter
double
Example
If an initial condition is fulfilled, 1 contract should be purchased at the current exchange rate.
GetCurrentSpread()
Description
The GetCurrentSpare () method returns the current spread.
See GetCurrentAsk, GetCurrentBid() and OnLevel1().
Usage
GetCurrentSpread()
Return Value
none
Parameter
double
Example
If an initial condition is fulfilled, 1 contract should be purchased at the current exchange rate.
GetDayAsInt()
Description
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.
Help with date-time: https://learn.microsoft.com/de-de/dotnet/api/system.datetime?view=net-8.0
Usage
GetDayAsInt(DateTime time)
Example
GetSeriesHighestValue
Description
The GetSeriesHighestValue() method searches within a predetermined number of periods for the highest bar and outputs how many bars ago it can be found.
Parameter
period Number of bars within which the bar is searched for
series Every data series, such as close, high, low, etc.
Return Value
Usage
Example
GetSeriesLowestValue
Description
The GetSeriesLowestValue() method attempts to find the lowest bar within a predefined number of periods.
Parameter
period Number of bars that will be searched for the lowest bar
series Every data series, such as close, high, low etc.
Return Value
int barsAgo How many bars ago the low occurred
Usage
Example
GetTimeAsInt()
Description
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.
Help with date-time: http://msdn.microsoft.com/de-de/library/system.datetime.aspx
Usage
GetTimeAsInt(DateTime time)
Example
Historical
Description
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
Historical
Return Value
true when using historical data false when using real-time data
Example
InputPriceType
Description
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
Usage
Example1
Example2
Instrument
Description
With "instrument", information concerning the trading instrument (stock, future etc.) is made available.
Detailed information can be found here: Instruments.
IsAddDrawingsToPricePanel
Description
The property "IsAddDrawingsToPricePanel" determines the panel in which the drawing objects are drawn.
Drawing objects are shown in the price chart
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
IsAddDrawingsToPricePanel
Example
IsAutoAdjustableScale
Description
IsAutoAdjustableScale is a property of indicators that can be set within the OnInit() method.
The price axis (y-axis) of the chart is set so that all plots and lines of an indicator are visible.
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
IsAutoAdjustableScale
Example
IsOverlay
Description
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
Example
IsProcessingBarIndexLast
Description
Indicates if current bar is last in calculation.
Parameter
None
Return value
Type bool
Usage
used for complicated calculation on a last bar
Example
IsSerieRising()
Description
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(), CrossBelow(), IsSerieRising(), IsSerieFalling().
Usage
Return Value
true If the data series is rising false If the data series is not rising
Parameter
series A data series such as an indicator, close, high etc.
Example
IsSerieFalling()
Description
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(), CrossBelow(), IsSerieRising(), IsSerieFalling().
Usage
Return Value
true If the data series is falling false If the data series is not falling
Parameter
series a data series such as an indicator, close, high etc.
Example
IsShowChartVerticalGrid
Description
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
IsShowChartVerticalGrid
Example
IsShowInDataBox
Description
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).
The indicator values are displayed in the data box.
The indicator values are not displayed in the data box.
The following image displays the values of 3 smoothed averages in the data box.
Usage
IsShowInDataBox
Example
IsShowPriceMarkers
Description
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
IsShowPriceMarkers
Example
Level1Args
Description
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
See OnLevel1().
Level2Args
Description
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
See OnLevel2().
LevelLine()
Description
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.
Parameter
Color | LevelLine color |
Name | Description |
Pen | A pen object |
Value | Defines which value on the y-axis the line will be drawn for |
Usage
More Information
Information on the pen class: https://learn.microsoft.com/de-de/dotnet/api/system.drawing.pen?view=dotnet-plat-ext-8.0
Example
Log()
Description
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
Parameter
message | Text (message) |
logLevel | Possible values are: InfoLogLevel.Info, InfoLogLevel.Message, InfoLogLevel.Warning, InfoLogLevel.ShowAlert, InfoLogLevel.Error |
Example
Crossreference: a crossreference to Print() and ShowAlert()
Occurred
Description
This DataSeries is used in conditions and indicates if signal occurred (1-long, -1 short, 0- no signal )
Parameter
None
Return value
Int
Usage
In scripted condition for short, long, none signal indication
Example
OnBarsRequirements()
Description
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
none
Return Value
none
Example
OnInit()
Description
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
none
Return Value
none
Usage
Important Keywords
IsAutoScale
Additional Keywords for Strategies
EntriesPerDirection
More Information
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
OutputDescriptor()
Description
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.
Parameter
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
More Information
Information on the pen class: http://msdn.microsoft.com/de-de/library/system.drawing.pen.aspx
Example
InputParameter()
Description
Attribute which used for indicator customization
Return Value
None
Parameter
None
Example
PlaySound()
Description
This method allows you to play a wav file.
Usage
PlaySound(wavFile)
Return Value
none
Parameter
wavFile File name of the wav file to be played
Example
PlotMethod
Description
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.
The Chart object offers several parameters.
More examples: Bar Numbering, PlotSample, Chart Background Image.
Parameter
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
none
Usage
Example
PriceType
Description
Price type describes a form of price data.
See InputPriceType
Following variables are available: - PriceType.Close - PriceType.High - PriceType.Low - PriceType.Median - PriceType.Open - PriceType.Typical - PriceType.Volume - PriceType.Weighted
Usage
PriceType
Example
See InputPriceType
Print()
Description
The Print() method writes outputs in the AgenaTrader output window. See ClearTraceWindow().
Usage
Parameter
string Text an individual message text
Return Value
none
More Information
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
Example
ProcessingBarIndex
Description
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
none
Return Value
Current bar is a variable of the type int, which always contains the number of the bar currently being used.
Usage
ProcessingBarIndex
More Information
The OnCalculate() method uses numbering different from that of ProcessingBarIndex in terms of the Barindex and Bars. 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
RemoveChartDrawing()
Description
The RemoveChartDrawing() method removes a specific drawing object from the chart based on a unique identifier (tag). See RemoveChartDrawings().
Usage
RemoveChartDrawings(string tag)
Return Value
none
Parameter
string tag The clearly identifiable name for the drawing object
Example
RemoveChartDrawings()
Description
This method removes all drawings from the chart See RemoveChartDrawings().
Usage
RemoveChartDrawings()
Return Value
none
Example
RequiredBarsCount
Description
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
RequiredBarsCount
Example
ShowAlert()
Description
The ShowAlert method creates an acoustic and/or visual alarm.
Usage
Return Value
None
Parameter
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
To use music files in a different path, you need to specify the path:
TickSize
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.
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 under Products & Trading Eurex (FDAX): http://www.eurexchange.com/exchange-en/products/idx/dax/17206/
See Instrument.TickSize.
TimeFrame
See Bars.TimeFrame.
When using multiple timeframes (Multibars) in an indicator, please see TimeFrames.
Update()
Description
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
Return Value
none
Parameter
none
Example
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:
Code from Ind2:
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
Description
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
Value
Value[int barsAgo]
More Information
The methods known for a collection, Set(), Reset(), and Count(), can be used for values.
Example
See Values.
Last updated