4.7.5.2 Receiving Data. TradingData.

From MultiCharts
Jump to: navigation, search

The ITradingData interface contains 4 properties that provide access to different data:

public interface ITradingData

  • IAccounts Accounts { get; } – provides access to account information which can be found at the Accounts tab of the Order and Position Tracker Window.
  • ILogs Logs { get; } – provides access to the event list information which can be found at the Logs tab of the Order and Position Tracker Window.
  • IOrders Orders { get; } - provides access to the orders list information which can be found at the Orders tab of the Order and Position Tracker Window.
  • IPositions Positions { get; } - provides access to the positions list information which can be found at the Positions tab of the Order and Position Tracker Window.

Each of these properties returns a reference to the interface of the corresponding list or collection. Each of these interfaces has a single basic interface - IDataSource<T>, where T is the certain type that describes the order, account, position, etc.


The IDataSource interface contains:

public interface IDataSource<T> {

  • event TItemsChanged<T> Added; - an event that is generated when the new elements are added into the collection. For example, for orders it means that a new order has been placed.
  • event TItemsChanged<T> Changed; - an event that is generated when the current components of the collection are changed. For example, for orders it means that the existing order has been changed. It can be a modification of its status, price, number of contracts or any other attributes.
  • event TItemsChanged<T> Deleted; - an event that is generated when the current elements of the collection have been removed. For example, for positions it means that it has been closed or has become Flat.
  • event EventHandler FinishChanging; - an event that is generated at the end of batch changes.
  • event EventHandler ReloadFinished; - an event that is generated after the collection has been completely changed.
  • event EventHandler ReloadStarted; - an event that is generated before the collection is changed. It can be generated, for example, if a filter is applied.
  • event EventHandler StartChanging; - an event that is generated before batch modifications start. Usually, “batch modification” means a single generation of each event such asAdded, Changed, and Deleted events.
  • T[] Items { get; } – is a property for accessing all of the available components of the collection.


Please NOTE, that this property returns a copy of the data but not the reference to the place where it is stored.


All of the above mentioned events are generated at strictly defined moments, for example, when a position or order update event is received from the broker. Respectively, the updating of the collection elements that are accessed via the Items property is also performed at a strictly defined moment. This moment is defined by calling the ITradeManager.ProcessEvents() method.

All collected events, elements collection changes, events from IDataSource<T> interface that start being generated, on all the elements for a current moment start being applied within this call and the current thread. The chronological order of the events within a single collection stays the same. The reason for this is that the indicator/signal is not a stand-alone application but a component that should be executed in certain conditions and environment.

All of the collection interfaces, ILogs, IOrders, and IPositions except for IAccounts, have the properties for accessing the filters. The filters allow you to exclude unnecessary elements that do not correspond to the filters conditions. There are two types of filters:

1. Time-based. This filter type is available in the following interface:

interface IDateTimeFilter 
{
    DateTime From { get; set; }
    DateTime To { get; set; }
}

Where the “From To” properties set the complete (closed) range of the time period [From, To].

2. List-based. This filter type is available in the following interface:

interface IBaseFilter<T>
{
        bool CurrentIsAll { get; } //– If TRUE then the filter value has not been set. 
	T CurrentValue { get; set; } //– a current filter value.
	T[] Values { get; } //– the list of all the possible filter values.
}

where T can be either a string or an enumeration.


As soon as the new value is set for any property, the collection is filtered on the new value of the filter: synchronously if the new value of the filter is deemed to be a subset of the previous value or asynchronously in all other cases.