Class Extensions
- Namespace
- ATAS.Indicators
- Assembly
- ATAS.Indicators.dll
Contains extension methods for various types.
public static class Extensions
- Inheritance
-
objectExtensions
Fields
AxisTextFormat
The format used for axis text.
public static readonly RenderStringFormat AxisTextFormat
Field Value
Methods
CalcAverage(IDataSeries, int, int)
Calculates the average value of a data series within a specified period.
public static decimal CalcAverage(this IDataSeries series, int period, int bar)
Parameters
seriesIDataSeriesThe data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The calculated average value.
CalcAverage(IDataSeries<decimal>, int, int)
Calculates the average value of a data series within a specified period.
public static decimal CalcAverage(this IDataSeries<decimal> series, int period, int bar)
Parameters
seriesIDataSeries<decimal>The data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The calculated average value.
CalcSum(IDataSeries, int, int)
Calculates the sum of a data series within a specified period.
public static decimal CalcSum(this IDataSeries series, int period, int bar)
Parameters
seriesIDataSeriesThe data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The calculated sum.
CalcSum(IDataSeries<decimal>, int, int)
Calculates the sum of a data series within a specified period.
public static decimal CalcSum(this IDataSeries<decimal> series, int period, int bar)
Parameters
seriesIDataSeries<decimal>The data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The calculated sum.
Calculate(Indicator, int, decimal)
Calculates the value of an indicator for a specific bar and stores it in the source data series.
public static decimal Calculate(this Indicator indicator, int bar, decimal value)
Parameters
indicatorIndicatorThe indicator.
barintThe current bar number.
valuedecimalThe value to store in the source data series.
Returns
- decimal
The calculated indicator value.
Convert(Color)
Converts a System.Drawing.Color to a System.Windows.Media.Color.
public static Color Convert(this Color color)
Parameters
colorColorThe System.Drawing.Color to convert.
Returns
- Color
The equivalent System.Windows.Media.Color.
Convert(Color)
Converts a System.Windows.Media.Color to a System.Drawing.Color.
public static Color Convert(this Color color)
Parameters
colorColorThe System.Windows.Media.Color to convert.
Returns
- Color
The equivalent System.Drawing.Color.
DrawLabelOnPriceAxis(Indicator, RenderContext, string, int, RenderFont, Color, Color)
Draws a label on the price axis of the chart's render context.
public static void DrawLabelOnPriceAxis(this Indicator indicator, RenderContext context, string text, int y, RenderFont font, Color fillColor, Color textColor)
Parameters
indicatorIndicatorThe Indicator instance.
contextRenderContextThe RenderContext instance.
textstringThe text of the label.
yintThe Y-coordinate of the label.
fontRenderFontThe font of the label.
fillColorColorThe background color of the label.
textColorColorThe text color of the label.
GetDescription(BaseIndicator, bool, bool, bool, bool)
Gets the description of the BaseIndicator.
public static string GetDescription(this BaseIndicator indicator, bool showSeries = true, bool showParameters = true, bool showInstrument = false, bool showTimeFrame = false)
Parameters
indicatorBaseIndicatorThe BaseIndicator instance.
showSeriesbooltrue to show the series information in the description, otherwise false.
showParametersbooltrue to show the parameter information in the description, otherwise false.
showInstrumentbooltrue to show the instrument information in the description, otherwise false.
showTimeFramebooltrue to show the time frame information in the description, otherwise false.
Returns
- string
The description of the BaseIndicator.
GetDescription(BaseIndicator, string, bool, bool, bool, bool)
Gets the description of the BaseIndicator built on top of an explicit display name instead of the current Name. Use it when the indicator derives its Name from the description itself, otherwise every rebuild would append the parameters to the previous description (PLAT-5163).
Not in ATAS 8.0.15 yet: available from the next version.
public static string GetDescription(this BaseIndicator indicator, string displayName, bool showSeries = true, bool showParameters = true, bool showInstrument = false, bool showTimeFrame = false)
Parameters
indicatorBaseIndicatorThe BaseIndicator instance.
displayNamestringThe name the description starts with.
showSeriesbooltrue to show the series information in the description, otherwise false.
showParametersbooltrue to show the parameter information in the description, otherwise false.
showInstrumentbooltrue to show the instrument information in the description, otherwise false.
showTimeFramebooltrue to show the time frame information in the description, otherwise false.
Returns
- string
The description of the BaseIndicator.
GetIndicatorCandle(ExtendedIndicator, int)
Gets the IndicatorCandle at a specified bar for the given ExtendedIndicator.
public static IndicatorCandle GetIndicatorCandle(this ExtendedIndicator indicator, int bar)
Parameters
indicatorExtendedIndicatorThe ExtendedIndicator instance.
barintThe bar number.
Returns
- IndicatorCandle
The IndicatorCandle at the specified bar.
GetTimeFrameTypeChartPeriod(IChart)
Returns the chart period as a System.TimeSpan based on the TimeFrame value. Supports minute (M), hour (H), daily, and weekly formats.
Added in ATAS 8.0.15.
public static TimeSpan GetTimeFrameTypeChartPeriod(this IChart chartInfo)
Parameters
Returns
- TimeSpan
A System.TimeSpan representing the specified period.
Exceptions
- ArgumentNullException
Thrown when
chartInfois null.- ArgumentException
Thrown when
chartInfo.ChartType.ChartTypeis notTimeFrameor when the provided time frame format is invalid or unsupported.
GetWithTransparency(Color, int)
Gets a System.Drawing.Color equal to the given one with added transparency.
public static Color GetWithTransparency(this Color color, int transparency)
Parameters
colorColortransparencyintThe transparency range is from 0 to 100.
Returns
- Color
System.Drawing.Color with a given transparency.
GetWithTransparency(Color, int)
Gets a System.Windows.Media.Color equal to the given one with added transparency.
public static Color GetWithTransparency(this Color color, int transparency)
Parameters
colorColortransparencyintThe transparency range is from 0 to 100.
Returns
- Color
System.Windows.Media.Color with a given transparency.
GetXByBar(IChart, int, bool)
Gets the X-coordinate of a bar on the chart.
public static int GetXByBar(this IChart chart, int bar, bool isStartOfBar = true)
Parameters
chartIChartThe IChart instance.
barintThe bar number.
isStartOfBarbooltrue to get the X-coordinate of the start of the bar, false to get the X-coordinate of the middle of the bar.
Returns
- int
The X-coordinate of the bar on the chart.
GetYByPrice(IChart, decimal, bool)
Gets the Y-coordinate of a price on the chart.
public static int GetYByPrice(this IChart chart, decimal price, bool isStartOfPriceLevel = true)
Parameters
chartIChartThe IChart instance.
pricedecimalThe price value.
isStartOfPriceLevelbooltrue to get the Y-coordinate of the start of the price level, false to get the Y-coordinate of the middle of the price level.
Returns
- int
The Y-coordinate of the price on the chart.
IsEqual(CumulativeTrade, CumulativeTrade)
Checks if two CumulativeTrade objects are equal.
public static bool IsEqual(this CumulativeTrade trade1, CumulativeTrade trade2)
Parameters
trade1CumulativeTradeThe first CumulativeTrade object.
trade2CumulativeTradeThe second CumulativeTrade object.
Returns
- bool
true if the CumulativeTrade objects are equal, otherwise false.
IsKeyPressed(IChart, Key)
Checks if a specific key is currently pressed on the chart's keyboard.
public static bool IsKeyPressed(this IChart chart, Key key)
Parameters
Returns
IsNewIndicatorMonth(Indicator, int)
Checks if a new month has started for the indicator at a specified bar.
public static bool IsNewIndicatorMonth(this Indicator indicator, int bar)
Parameters
Returns
IsNewIndicatorSession(Indicator, int)
Checks if a new session has started for the indicator at a specified bar.
public static bool IsNewIndicatorSession(this Indicator indicator, int bar)
Parameters
Returns
IsNewIndicatorWeek(Indicator, int)
Checks if a new week has started for the indicator at a specified bar.
public static bool IsNewIndicatorWeek(this Indicator indicator, int bar)
Parameters
Returns
MAX(IDataSeries, int, int)
Finds the maximum value of a data series within a specified period.
public static decimal MAX(this IDataSeries series, int period, int bar)
Parameters
seriesIDataSeriesThe data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The maximum value.
MAX(IDataSeries<decimal>, int, int)
Finds the maximum value of a data series within a specified period.
public static decimal MAX(this IDataSeries<decimal> series, int period, int bar)
Parameters
seriesIDataSeries<decimal>The data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The maximum value.
MIN(IDataSeries, int, int)
Finds the minimum value of a data series within a specified period.
public static decimal MIN(this IDataSeries series, int period, int bar)
Parameters
seriesIDataSeriesThe data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The minimum value.
MIN(IDataSeries<decimal>, int, int)
Finds the minimum value of a data series within a specified period.
public static decimal MIN(this IDataSeries<decimal> series, int period, int bar)
Parameters
seriesIDataSeries<decimal>The data series.
periodintThe period for the calculation.
barintThe current bar number.
Returns
- decimal
The minimum value.
RenderRightAxisLabel(RenderContext, int, int, string, Color, Color, RenderFont)
Renders a right axis label on the chart's render context.
public static void RenderRightAxisLabel(this RenderContext context, int x, int y, string text, Color background, Color textColor, RenderFont font)
Parameters
contextRenderContextThe RenderContext instance.
xintThe X-coordinate of the label.
yintThe Y-coordinate of the label.
textstringThe text of the label.
backgroundColorThe background color of the label.
textColorColorThe text color of the label.
fontRenderFontThe font of the label.
To(LineDashStyle)
Converts a LineDashStyle to a System.Drawing.Drawing2D.DashStyle.
public static DashStyle To(this LineDashStyle style)
Parameters
styleLineDashStyleThe LineDashStyle to convert.
Returns
- DashStyle
The equivalent System.Drawing.Drawing2D.DashStyle.
To(DashStyle)
Converts a System.Drawing.Drawing2D.DashStyle to a LineDashStyle.
public static LineDashStyle To(this DashStyle style)
Parameters
styleDashStyleThe System.Drawing.Drawing2D.DashStyle to convert.
Returns
- LineDashStyle
The equivalent LineDashStyle.