Interface ICandleSeriesSubscription
- Namespace
- ATAS.Indicators
- Assembly
- ATAS.Indicators.dll
A live candle series: history plus live updates. Implements ICandleCreator, so it plugs directly into CandlePartSeries (and through it into nested indicators' SourceDataSeries). Dispose to release.
The per-candle events cover LIVE updates only: history snapshots (initial load, reloads) are applied silently to Candles and signalled by Reloaded - re-read the list there instead of expecting OnNewCandle per historical candle.
Threading: OnNewCandle, OnRemoveCandle and OnCandleChanged fire on the SOURCE instrument's data-processing thread — for another instrument this is a different thread than the chart's own callbacks. Handlers must be fast (a slow handler stalls that instrument's data pipeline); use DoActionInGuiThread(Action) for UI work. Loaded continuations run by normal task-scheduling rules (thread pool), not on the source thread. Read Candles from the candle events (or copy a snapshot there) — the list is appended on the source thread.
Added in ATAS 8.0.15.
public interface ICandleSeriesSubscription : ICandleCreator
- Inherited Members
- Extension Methods
Properties
Instrument
The resolved instrument name (chart's instrument when Instrument is null or empty).
string Instrument { get; }
Property Value
- string
IsLoaded
True when history is loaded and live updates are flowing.
bool IsLoaded { get; }
Property Value
- bool
Loaded
Completes when history is loaded and live updates are flowing; faults with the load error otherwise. Replaced with a new task when the source resets (reconnect/rollover) and the series reloads.
Task Loaded { get; }
Property Value
- Task
Request
The request this subscription was created from.
CandleSeriesRequest Request { get; }
Property Value
Methods
GetCandleByTime(DateTime)
The last candle that had started at or before the given time, or null when the series has no such candle. Binary search; call from a candle event or the chart's calculation callbacks (the list is appended on the source instrument's data thread).
LOOKAHEAD WARNING: the returned candle may still have been FORMING at
time - on historical data its OHLCV are the final values, which
were not known at that moment. An indicator that reads them for historical chart bars
looks into the future and will repaint (its historical and live values diverge).
For historical calculations use GetClosedCandleByTime(DateTime); use this method
for the live forming value only.
IndicatorCandle? GetCandleByTime(DateTime time)
Parameters
timeDateTime
Returns
GetClosedCandleByTime(DateTime)
The last candle that was already CLOSED at the given time (its successor had started
at or before time), or null when the series has no such candle.
This is the anti-repaint lookup for historical calculations: the returned candle's
values were fully known at time, so historical and live results
match. Conservative by construction - a candle is only considered closed once the
next one exists. Same threading rules as GetCandleByTime(DateTime).
IndicatorCandle? GetClosedCandleByTime(DateTime time)
Parameters
timeDateTime
Returns
LoadMoreHistoryAsync(int)
Deepens the loaded history to at least the given number of trading days without resubscribing. The returned task is the new Loaded. No-op (returns the current Loaded) when the series is already at least that deep. The host clamps the depth the same way as the initial request.
Task LoadMoreHistoryAsync(int days)
Parameters
daysint
Returns
- Task
Events
Reloaded
Raised every time the series content is rebuilt: after the initial history load AND after automatic reloads (source reset on reconnect/rollover/replay transitions, deeper history). Consumers should re-read Candles and recalculate - the Loaded task instance is replaced on reloads, so a one-shot continuation on it misses them. When a reload FAILED the series is empty and Loaded is faulted with the reason. A handler attached after the series is already loaded is invoked immediately (replay-on-attach), so this event alone is sufficient to drive a consumer. Threading: fires on background/data threads, and on the attaching thread for the replay-on-attach delivery - never assume the UI thread.
event Action<ICandleSeriesSubscription>? Reloaded
Event Type
- Action<ICandleSeriesSubscription>