ATAS
Loading...
Searching...
No Matches
Development of a user indicator

Basics

In order to develop a user indicator, it is necessary:

  1. To create a class library project in Visual Studio.
  2. To add a link to ATAS.Indicators.dll, which is in the folder with the installed program, in the project.
  3. Redefine the Indicator class.
  4. Add the necessary DataSeries - ValueDataSeries, RangeDataSeries, CandleDataSeries, CandlePartSeries, IndicatorSeries, PriceSelectionDataSeries, PaintbarsDataSeries or ObjectDataSeries - in the constructor.
  5. Describe the logic of the indicator operation in the OnCalculate() function.
  6. Compile the library.
  7. Place the obtained dll file into the Documents/ATAS/Indicators folder.
  8. After adding a file with an indicator, a blinking button will appear on the bottom panel, indicating that the list of indicators has been updated. The developed indicator will appear in the list of platform indicators after clicking this button.
Update the list of indicators

You can get examples from our GitHub repository here. You need to add the current version of ATAS.Indicators.dll in the references of this project.

Example of the indicator development

Create MyCustomIndicator class and inherit it from Indicator:

public class MyCustomIndicator : Indicator
{
protected override void OnCalculate(int bar, decimal value)
{
}
}
Base class for custom indicators.
Definition Indicator.cs:42
Definition FeatureId.cs:2

Identify the constructor. Add a required number of DataSeries if required. Each indicator has one ValueDataSeries by default. Add one more ValueDataSeries in this example.

public MyCustomIndicator() : Indicator
{
DataSeries.Add(new ValueDataSeries("Values"));
}
void Add(Indicator indicator)
Adds an indicator to the list of used indicators by this indicator.
Definition BaseIndicator.cs:451
Represents a data series of decimal values, each element is a decimal.
Definition ValueDataSeries.cs:26

Identify the logic of the indicator operation. For example, we need an indicator, which shows maximum values of the incoming DataSeries for 10 recent bars:

public MyCustomIndicator() : Indicator
{
protected override void OnCalculate(int bar, decimal value)
{
var period = 10;
var start = Math.Max(0, bar - Period + 1);
var count = Math.Min(bar + 1, Period);
var max = (decimal)SourceDataSeries[start];
for (var i = start + 1; i < start + count; i++)
{
max = Math.Max(max, (decimal)SourceDataSeries[i]);
}
this[bar] = max;
}
}

The OnCalculate method is called for each bar in the history and, further on, it is called at each tick. All bars and values of the respective DataSeries have sequence numbers. Number 0 refers to the earliest chart bar, the next bar has number 1 and so on. Value, which is passed to this method, depends on Source, which a user can select. Open, High, Low and Close of candles and value of other indicators could be used as the source.

Source value

There could be situations when an indicator doesn’t need to have a possibility to select the source (for example, these are indicators, which use only the candle data in their calculations). In such a case, the Select section could be hidden. To do it, it is necessary to call the basic constructor with the true parameter.

public MyCustomIndicator(): base(true)
{
}