Class ExtendedIndicator
- Namespace
- ATAS.Indicators
- Assembly
- ATAS.Indicators.dll
An extended base class for custom indicators that provide additional functionality for drawing, alerts, market data handling, etc.
[DataContract]
public abstract class ExtendedIndicator : BaseIndicator, INotifyPanelPropertyChanged, IPropertiesEditorOwner, IMarketTimeProvider
- Inheritance
-
objectExtendedIndicator
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
ExtendedIndicator(DataSeriesType)
Initializes the indicator with a price series of the chart as the default source.
protected ExtendedIndicator(DataSeriesType seriesType)
Parameters
seriesTypeDataSeriesTypeThe price series to take as the default source (Open, High, Low, Close, ...).
ExtendedIndicator(bool)
Initializes the indicator.
protected ExtendedIndicator(bool useCandles = false)
Parameters
useCandlesbooltrue to take the candles of the chart as the default source; false to take the Close price series.
Properties
AlertsEnabled
Gets or sets a value indicating whether the alerts of the indicator are on. Saved with the indicator; a hidden indicator with alerts on keeps receiving the cumulative trades it requested.
Added in ATAS 8.0.15.
[DataMember]
[Browsable(false)]
public virtual bool AlertsEnabled { get; set; }
Property Value
- bool
Container
Gets or sets the container in which the indicator is hosted.
[Browsable(false)]
[IgnoreDataMember]
public IIndicatorContainer? Container { get; set; }
Property Value
DataProvider
Gets or sets the data provider for the indicator.
[Browsable(false)]
[IgnoreDataMember]
public IIndicatorDataProvider? DataProvider { get; set; }
Property Value
DenyToChangePanel
Gets or sets a value indicating whether changing the indicator's panel is denied. For vertical indicators, it is always denied.
[DataMember]
[Browsable(false)]
public bool DenyToChangePanel { get; set; }
Property Value
- bool
DrawAbovePrice
Gets or sets a value indicating whether custom painting should be performed on top of rendered bars.
[Browsable(false)]
[IgnoreDataMember]
public bool DrawAbovePrice { get; set; }
Property Value
- bool
EnableCustomDrawing
Gets or sets a value indicating whether custom drawing is enabled for the indicator.
[Browsable(false)]
[IgnoreDataMember]
public bool EnableCustomDrawing { get; protected set; }
Property Value
- bool
FullScreenMode
Gets or sets full screen mode for the indicator. Could be applied only to the vertical indicators('IsVerticalIndicator = true')
[Browsable(false)]
[DataMember]
public bool FullScreenMode { get; set; }
Property Value
- bool
HorizontalLinesTillTouch
Gets the collection of horizontal lines used to track touch points on the chart.
[Browsable(false)]
[IgnoreDataMember]
public List<LineTillTouch> HorizontalLinesTillTouch { get; }
Property Value
- List<LineTillTouch>
IsLoading
Indicates that the indicator is still loading its data. While set, the chart indicators legend shows a loading marker next to the indicator name.
Added in ATAS 8.0.15.
[Browsable(false)]
[IgnoreDataMember]
public bool IsLoading { get; set; }
Property Value
- bool
Labels
Gets or sets the collection of named drawing text elements.
[Browsable(false)]
[IgnoreDataMember]
public SyncDictionary<string, DrawingText> Labels { get; set; }
Property Value
- SyncDictionary<string, DrawingText>
MarketByOrders
Gets a snapshot of the current market by order data.
protected IEnumerable<MarketByOrder> MarketByOrders { get; }
Property Value
- IEnumerable<MarketByOrder>
MarketTime
Current market time.
[Browsable(false)]
public DateTime MarketTime { get; }
Property Value
- DateTime
Rectangles
Gets the collection of rectangles on the chart.
[Browsable(false)]
[IgnoreDataMember]
public List<DrawingRectangle> Rectangles { get; }
Property Value
- List<DrawingRectangle>
ShowDescription
Gets or sets a value indicating whether the description of the indicator should be shown.
[Parameter]
[Tab(TabName = "Visualization", ResourceType = typeof(Strings))]
[Display(ResourceType = typeof(Strings), Name = "ShowDescription", Description = "ShowDescriptionDescription", GroupName = "Misc")]
public bool ShowDescription { get; set; }
Property Value
- bool
Storage
Gets path-free storage scoped to this indicator.
Not in ATAS 8.0.15 yet: available from the next version.
[Browsable(false)]
[IgnoreDataMember]
protected IIndicatorStorage Storage { get; }
Property Value
SupportsCalculationTimeFrame
Gets or sets a value indicating whether the indicator can be calculated on a timeframe other than the chart's (CalculationTimeFrame, PLAT-4527). Off by default: the "Timeframe" parameter is hidden and a timeframe restored from a template is ignored. Set it to true in the constructor of an indicator that only needs OHLCV candles of the higher timeframe (moving averages, oscillators, ATR-style ranges). Indicators bound to the chart's bar structure (cluster/footprint, order flow, DOM) must leave it off - the shadow higher-timeframe candles carry no cluster data. A type trait, not a user setting: never persisted.
Not in ATAS 8.0.15 yet: available from the next version.
[IgnoreDataMember]
[Browsable(false)]
public bool SupportsCalculationTimeFrame { get; set; }
Property Value
- bool
SupportsCalculationTimeFrameSmoothing
Gets or sets a value indicating whether the projected higher-timeframe values may be drawn as a smooth line (CalculationTimeFrameSmoothing, PLAT-4527). On by default. Set it to false in the constructor of an indicator whose output is a set of levels rather than a curve (trailing stops, support/resistance, square/dot visuals): ramping between two levels draws values the indicator never had. The "Smooth line" parameter is then hidden and ignored. A type trait, not a user setting: never persisted.
Not in ATAS 8.0.15 yet: available from the next version.
[IgnoreDataMember]
[Browsable(false)]
public bool SupportsCalculationTimeFrameSmoothing { get; set; }
Property Value
- bool
TrendLines
Gets the collection of trend lines on the chart.
[Browsable(false)]
[IgnoreDataMember]
public List<TrendLine> TrendLines { get; }
Property Value
- List<TrendLine>
UtcTime
Current UTC time.
[Browsable(false)]
public DateTime UtcTime { get; }
Property Value
- DateTime
Methods
AddAlert(string, string)
Adds an alert with the specified sound file and message to the chart.
protected void AddAlert(string soundFile, string message)
Parameters
soundFilestringThe file path of the sound to be played when the alert is triggered.
messagestringThe message to be displayed in the alert.
AddAlert(string, string, string, Color, Color)
Adds an alert for a specific instrument with custom properties.
protected void AddAlert(string soundFile, string instrument, string message, Color background, Color foreground)
Parameters
soundFilestringThe file path or name of the sound file to be played for the alert.
instrumentstringThe name of the instrument or symbol associated with the alert.
messagestringThe message or description of the alert.
backgroundColorThe background color to be used for the alert visualization.
foregroundColorThe foreground color to be used for the alert visualization.
AddAlert(string, string, string, Color, Color, bool)
Adds an alert and controls whether a popup notification is shown.
Not in ATAS 8.0.15 yet: available from the next version.
protected void AddAlert(string soundFile, string instrument, string message, Color background, Color foreground, bool showPopup)
Parameters
soundFilestringinstrumentstringmessagestringbackgroundColorforegroundColorshowPopupbool
AddAlert(string, string, string, Color, Color, DateTime)
Adds an alert for a specific instrument with custom properties.
Added in ATAS 8.0.15.
protected void AddAlert(string soundFile, string instrument, string message, Color background, Color foreground, DateTime time)
Parameters
soundFilestringThe file path or name of the sound file to be played for the alert.
instrumentstringThe name of the instrument or symbol associated with the alert.
messagestringThe message or description of the alert.
backgroundColorThe background color to be used for the alert visualization.
foregroundColorThe foreground color to be used for the alert visualization.
timeDateTimeExact time for alert
AddHorizontalLineTillTouch(LineTillTouch)
Adds a horizontal line and tracks it for touch calculation without scanning drawing history. Prefer this method to adding directly to HorizontalLinesTillTouch.
Not in ATAS 8.0.15 yet: available from the next version.
protected void AddHorizontalLineTillTouch(LineTillTouch line)
Parameters
lineLineTillTouch
AddText(string, string, bool, int, decimal, int, int, Color, Color, Color, float, TextAlign, bool)
Adds a drawing text element to the chart at the specified position.
protected DrawingText AddText(string tag, string text, bool isAbovePrice, int bar, decimal price, int yOffset, int xOffset, Color textColor, Color outlineColor, Color fillColor, float fontSize, DrawingText.TextAlign align, bool autoSize = false)
Parameters
tagstringA unique tag or identifier for the text element.
textstringThe actual text to be displayed.
isAbovePriceboolA boolean flag indicating whether the text should be displayed above the price or not.
barintThe index of the bar where the text should be displayed.
pricedecimalThe price at which the text should be displayed.
yOffsetintThe vertical offset of the text from its default position.
xOffsetintThe horizontal offset of the text from its default position.
textColorColorThe color of the text.
outlineColorColorThe color used for the outline of the text.
fillColorColorThe fill color of the text background.
fontSizefloatThe font size of the text.
alignDrawingText.TextAlignThe text alignment within its bounding box.
autoSizeboolA boolean flag indicating whether the text should be auto-sized or not.
Returns
- DrawingText
The created DrawingText object.
ApplyDefaultColors()
Applies default colors to the drawing elements.
public void ApplyDefaultColors()
Remarks
This method triggers the OnApplyDefaultColors() virtual method, which can be overridden in derived classes to customize the default color settings for the drawing elements.
Calculate(int, decimal)
Performs the calculation for the indicator at the specified bar and value.
protected override void Calculate(int bar, decimal value)
Parameters
barintThe bar number for which the calculation is performed.
valuedecimalThe input value from the data series at the specified bar.
ClearHorizontalLinesTillTouch()
Clears horizontal drawing history and the active touch-calculation list.
Not in ATAS 8.0.15 yet: available from the next version.
protected void ClearHorizontalLinesTillTouch()
Dispose()
Releases the indicator: calls OnDispose(), clears its values and series, detaches the source and disposes the indicators it uses. A second call does nothing.
public override void Dispose()
Draw(RenderContext, DrawingLayouts)
Draws the custom content of the indicator on one layout: calls OnRender(RenderContext, DrawingLayouts) when the layout is one of those set with SubscribeToDrawingEvents(DrawingLayouts) (only LatestBar by default). Called by the platform.
public void Draw(RenderContext context, DrawingLayouts layout)
Parameters
contextRenderContextThe rendering context of the chart.
layoutDrawingLayoutsThe layout being drawn.
GetCandle(int)
Gets the IndicatorCandle object at the specified bar index.
protected IndicatorCandle GetCandle(int bar)
Parameters
barintThe index of the bar for which to retrieve the IndicatorCandle.
Returns
- IndicatorCandle
The IndicatorCandle object at the specified bar index.
GetFixedProfile(FixedProfileRequest)
Requests fixed profile data from the online data provider.
[Obsolete("Use RequestFixedProfileAsync instead.")]
protected void GetFixedProfile(FixedProfileRequest request)
Parameters
requestFixedProfileRequestThe request object containing information about the fixed profile data to be fetched.
GetMarketByOrdersCache(TimeSpan)
Returns a market by order data cache.
protected IMarketByOrdersCache GetMarketByOrdersCache(TimeSpan period)
Parameters
periodTimeSpanSpecifies the time period for which Market-by-Order updates are stored in IMarketByOrdersCache.
Returns
- IMarketByOrdersCache
The IMarketByOrdersCache object representing the current state and allowing to receive real-time updates.
GetMarketByOrdersWithTradesCache(TimeSpan)
Returns a market by order data and trades cache.
protected IMarketByOrdersWithTradesCache GetMarketByOrdersWithTradesCache(TimeSpan period)
Parameters
periodTimeSpanSpecifies the time period for which trades are stored in IMarketByOrdersWithTradesCache.
Returns
- IMarketByOrdersWithTradesCache
The IMarketByOrdersWithTradesCache object representing the cache.
GetTradesCache(TimeSpan)
Returns a trades cache.
protected ITradesCache GetTradesCache(TimeSpan period)
Parameters
periodTimeSpanSpecifies the time period for which trades are stored in ITradesCache.
Returns
- ITradesCache
The ITradesCache object representing the trades cache.
MarketDepthChanged(MarketDataArg)
Handles changes in a single market depth represented by a MarketDataArg object.
protected virtual void MarketDepthChanged(MarketDataArg depth)
Parameters
depthMarketDataArgThe MarketDataArg representing the market depth data.
MarketDepthsChanged(IEnumerable<MarketDataArg>)
Handles changes in multiple market depths represented by an System.Collections.Generic.IEnumerable<T> of MarketDataArg.
protected virtual void MarketDepthsChanged(IEnumerable<MarketDataArg> depths)
Parameters
depthsIEnumerable<MarketDataArg>The collection of MarketDataArg representing the market depth data.
OnApplyDefaultColors()
Invoked to apply default colors to the drawing elements.
protected virtual void OnApplyDefaultColors()
Remarks
This method can be overridden in derived classes to customize or set default color values for the drawing elements. When this method is called, it is an opportunity for the derived class to apply its own default color scheme to the drawing elements used in the specific implementation.
OnBestBidAskChanged(MarketDataArg)
Handles changes in the best bid or ask prices in the market depth represented by a MarketDataArg object.
protected virtual void OnBestBidAskChanged(MarketDataArg depth)
Parameters
depthMarketDataArgThe MarketDataArg representing the market depth data.
OnContainerChanged(IIndicatorContainer?)
This method is called when the value of the Container property changes.
Added in ATAS 8.0.15.
protected virtual void OnContainerChanged(IIndicatorContainer? container)
Parameters
containerIIndicatorContainerThe new value of the IIndicatorContainer that the indicator is attached to.
OnCumulativeTrade(CumulativeTrade)
Handles a cumulative trade event represented by a CumulativeTrade object.
protected virtual void OnCumulativeTrade(CumulativeTrade trade)
Parameters
tradeCumulativeTradeThe CumulativeTrade representing the cumulative trade data.
OnCumulativeTradesResponse(CumulativeTradesRequest, IEnumerable<CumulativeTrade>)
Called when a response for a cumulative trades request is received.
protected virtual void OnCumulativeTradesResponse(CumulativeTradesRequest request, IEnumerable<CumulativeTrade> cumulativeTrades)
Parameters
requestCumulativeTradesRequestThe CumulativeTradesRequest object representing the original request.
cumulativeTradesIEnumerable<CumulativeTrade>The collection of CumulativeTrade representing cumulative trades data.
OnDataProviderChanged(IIndicatorDataProvider?, IIndicatorDataProvider?)
This method is called when the value of the DataProvider property changes.
Added in ATAS 8.0.15.
protected virtual void OnDataProviderChanged(IIndicatorDataProvider? oldDataProvider, IIndicatorDataProvider? newDataProvider)
Parameters
oldDataProviderIIndicatorDataProviderThe old IIndicatorDataProvider value.
newDataProviderIIndicatorDataProviderThe new IIndicatorDataProvider value.
OnFixedProfilesResponse(IndicatorCandle, FixedProfilePeriods)
Called with the fixed profile requested by the obsolete fixed profile request; use RequestFixedProfileAsync(FixedProfileRequest) instead.
[Obsolete("Use RequestFixedProfileAsync instead.")]
protected virtual void OnFixedProfilesResponse(IndicatorCandle fixedProfile, FixedProfilePeriods period)
Parameters
fixedProfileIndicatorCandleThe fixed profile.
periodFixedProfilePeriodsThe period of the fixed profile.
OnFixedProfilesResponse(IndicatorCandle, IndicatorCandle, FixedProfilePeriods)
This method is called when the online data provider responds with fixed profile data. Override this method in derived classes to handle the received fixed profile data.
[Obsolete("Use RequestFixedProfileAsync instead.")]
protected virtual void OnFixedProfilesResponse(IndicatorCandle fixedProfileScaled, IndicatorCandle fixedProfileOriginScale, FixedProfilePeriods period)
Parameters
fixedProfileScaledIndicatorCandleThe fixed profile data scaled to a specific period.
fixedProfileOriginScaleIndicatorCandleThe fixed profile data without scaling.
periodFixedProfilePeriodsThe period of the fixed profile data (e.g., daily, weekly, monthly, etc.).
OnMarketByOrdersChanged(IEnumerable<MarketByOrder>)
Handles a collection of market by order data represented by MarketByOrder objects.
protected virtual void OnMarketByOrdersChanged(IEnumerable<MarketByOrder> values)
Parameters
valuesIEnumerable<MarketByOrder>An IEnumerable of MarketByOrder representing the market by order data.
OnNewMyTrade(MyTrade)
Called when a new trade executed by the indicator's own strategy is received.
protected virtual void OnNewMyTrade(MyTrade myTrade)
Parameters
myTradeMyTradeThe new trade executed by the indicator's own strategy.
OnNewOrder(Order)
This method is called when a new order is received.
protected virtual void OnNewOrder(Order order)
Parameters
orderOrderThe new order that was received.
OnNewTrade(MarketDataArg)
Handles an individual trade represented by a MarketDataArg object.
protected virtual void OnNewTrade(MarketDataArg trade)
Parameters
tradeMarketDataArgThe MarketDataArg representing the trade data.
OnNewTrades(IEnumerable<MarketDataArg>)
Handles a collection of new trade data represented by MarketDataArg objects.
protected virtual void OnNewTrades(IEnumerable<MarketDataArg> trades)
Parameters
tradesIEnumerable<MarketDataArg>An IEnumerable of MarketDataArg representing the new trade data.
OnOrderCancelFailed(Order, string)
Called when an attempt to cancel an existing order fails.
protected virtual void OnOrderCancelFailed(Order order, string message)
Parameters
orderOrderThe order that failed to be canceled.
messagestringThe error message indicating the reason for the failure.
OnOrderChanged(Order)
Called when an existing order is modified (changed).
protected virtual void OnOrderChanged(Order order)
Parameters
orderOrderThe modified order.
OnOrderModifyFailed(Order, Order, string)
Called when an attempt to modify an existing order fails.
protected virtual void OnOrderModifyFailed(Order order, Order newOrder, string error)
Parameters
orderOrderThe order that failed to be modified.
newOrderOrderThe new order with the modifications that failed to be applied.
errorstringThe error message indicating the reason for the failure.
OnOrderRegisterFailed(Order, string)
Called when an attempt to register (place) a new order fails.
protected virtual void OnOrderRegisterFailed(Order order, string message)
Parameters
orderOrderThe order that failed to be registered.
messagestringThe error message indicating the reason for the failure.
OnPortfolioChanged(Portfolio)
This method is called when the value of the Portfolio changes.
It is raised on every update of the selected portfolio (balance, PnL, margin - typically on each tick while a position is open), not only when another portfolio is selected. Keep it cheap and do not re-subscribe market data or re-request data here unless the portfolio instance actually differs from the previous one.
protected virtual void OnPortfolioChanged(Portfolio portfolio)
Parameters
portfolioPortfolioThe new Portfolio value.
OnPortfolioSelected(Portfolio)
This method is called when another portfolio is selected on the chart (see PortfolioSelected).
It is the right place for work that has to be redone for the new account - reloading an option chain, re-requesting trading data, resetting per-account state. Use OnPortfolioChanged(Portfolio) instead to react to every update of the selected portfolio (balance, PnL, margin).
Added in ATAS 8.0.15.
protected virtual void OnPortfolioSelected(Portfolio portfolio)
Parameters
portfolioPortfolioThe newly selected Portfolio.
OnPositionChanged(Position)
This method is called when the value of the Position changes.
protected virtual void OnPositionChanged(Position position)
Parameters
positionPositionThe new Position value.
OnRender(RenderContext, DrawingLayouts)
Override this method for implementing your own data rendering logic.
protected virtual void OnRender(RenderContext context, DrawingLayouts layout)
Parameters
contextRenderContextThe rendering context used to draw on the chart.
layoutDrawingLayoutsThe layout information for the drawing.
OnSupportsCalculationTimeFrameChanged()
Called when SupportsCalculationTimeFrame changes - lets Indicator reconcile a running MTF calculation with the new state.
Not in ATAS 8.0.15 yet: available from the next version.
protected virtual void OnSupportsCalculationTimeFrameChanged()
OnUpdateCumulativeTrade(CumulativeTrade)
Handles an update event for a cumulative trade represented by a CumulativeTrade object.
protected virtual void OnUpdateCumulativeTrade(CumulativeTrade trade)
Parameters
tradeCumulativeTradeThe CumulativeTrade representing the updated cumulative trade data.
OnVisibleChanged()
Called when the Visible property changes. When the indicator becomes visible, sends the cumulative trades request that was postponed while the indicator was hidden and its alerts were disabled.
Added in ATAS 8.0.15.
protected override void OnVisibleChanged()
RecalculateValues()
Recalculate the indicator values on each bar.
protected override void RecalculateValues()
RedrawChart(RedrawArg?)
Call to redraw chart
protected void RedrawChart(RedrawArg? redrawArg = null)
Parameters
redrawArgRedrawArg
RemoveHorizontalLineTillTouchAt(int)
Removes a horizontal line by its index in HorizontalLinesTillTouch.
Not in ATAS 8.0.15 yet: available from the next version.
protected void RemoveHorizontalLineTillTouchAt(int index)
Parameters
indexint
ReplaceHorizontalLineTillTouch(int, LineTillTouch)
Replaces a horizontal line at its index in HorizontalLinesTillTouch.
Not in ATAS 8.0.15 yet: available from the next version.
protected void ReplaceHorizontalLineTillTouch(int index, LineTillTouch line)
Parameters
indexintlineLineTillTouch
RequestFixedProfileAsync(FixedProfileRequest)
Asynchronously requests a fixed market profile parameterized with FixedProfileRequest.
protected Task<FixedProfileResponse?> RequestFixedProfileAsync(FixedProfileRequest request)
Parameters
requestFixedProfileRequestThe request containing the fixed profile period.
Returns
- Task<FixedProfileResponse?>
RequestForCumulativeTrades(CumulativeTradesRequest)
Sends a request for cumulative trades data to the online data provider.
protected void RequestForCumulativeTrades(CumulativeTradesRequest request)
Parameters
requestCumulativeTradesRequestThe CumulativeTradesRequest object representing the request to be sent.
SubscribeMarketByOrderData()
Subscribes to the market by order data.
protected Task SubscribeMarketByOrderData()
Returns
- Task
SubscribeToDrawingEvents(DrawingLayouts)
Method for specifying the list of layouts in which rendering will be performed.
protected void SubscribeToDrawingEvents(DrawingLayouts flags)
Parameters
flagsDrawingLayoutsThe drawing layout flags indicating which events to subscribe to.
SubscribeToTimer(TimeSpan, Action)
Registers the callback and periodically calls it with specified period.
public void SubscribeToTimer(TimeSpan period, Action callback)
Parameters
periodTimeSpanA period of market data time used to repeatedly invoke the callback.
callbackActionA method that is called each time a specified period of market data time passes.
TryGetService<T>(out T?)
Gets a platform service the indicator can use (for example IAtasAccessTokenProvider).
Added in ATAS 8.0.15.
protected bool TryGetService<T>(out T? service)
Parameters
serviceTThe service, or null when it is not available.
Returns
- bool
true when the service is available; false when the platform does not provide it or the indicator is not attached to a chart yet.
Type Parameters
TThe type of the service.
UnsubscribeFromTimer(TimeSpan, Action)
Unregister the callback from periodic invocations.
public void UnsubscribeFromTimer(TimeSpan period, Action callback)
Parameters
periodTimeSpanSubscribed period of invocations.
callbackActionA method to be unregistered.