4.2 Data Access

Any study, whether it is an indicator or a signal, is an object that is applied to a price data series. Consequently, data and attributes of this data series are available from any study. Therefore, it is not important, which type of application we are working with in MultiCharts .NET: a chart, a scanner or a portfolio.

Data. A basis which all traders and market analysts are working with is price and volume data of various instruments. Visually, this data can be introduced as bars, which displays price movement for a particular period of time.

Access to the data from the study is executed through:

IInstrument Bars { get; }
IInstrument BarsOfData(int dataStream);

All the information about price data series bars from the current calculation point back to history can be extracted by means of this property and method. The BarsOfData() method allows to get data upon the secondary data series, applied to the chart or portfolio.

At creation any study is connected to a particular data stream, the one which it is applied to. This data stream is main source for this data series. The Bars property returns a reference to the object implemented via the Instrument interface and is related to the basic data series of the study.

There can be only one data stream in the scanner; it will be the main source for the study. Only indicators can be applied to scanner instruments.

In portfolio there can be several data streams, but only the first one can be basic for the studies, only strategies can be applied to portfolio.

There can be several data streams on the chart but for signals, like for the portfolio, only the first one will be the main source. For indicators, it can be any of applied to the chart.

The main data stream can be chosen in the indicator settings (click Format Study …, select Properties tab).

The BarsOfData(int dataNum) method should be used in order to access other data streams data, to be applied to the chart or (portfolio). The reference to the object, providing data of the specified instrument, will be returned according to the number of the data stream.

Data available through the IInstrument interface is described below.

Instrument Data

  • Prices: open, high, low, close of the current and previous count bars, for example:
double curClose = Bars.CloseValue;
- get current close price
double prevBarOpen = BarsOfData(2).Open[1];
- get open price of previous bar from second data stream
  • Volumes, ticks through the properties: Volume, Ticks, UpTicks, DownTicks, VolumeValue, TicksValue, UpTicksValue, DownTicksValue, for example:
double curVolume = Bars.VolumeValue;
- get current bar volume
  • Time: Bars.Time, Bars.TimeValue, for example:
DateTime prevBarTime = Bars.Time[1];
- get time of previous bar
  • Depth of Market data: the DOM property, for example:
if ( Bars.DOM.Ask[0].Size > 100 ) buy_order.Send();
- send buy order if first DOM level ask size more than 100
  • Status Line data: status line data when working either on the chart or scanner, for example:
double dailyLow = StatusLine.Low; </ syntaxhighlight>-  get daily low from status line.
===Data for Calculation===
* Current calculation bar: the CurrentBar property, for example:
<syntaxhighlight>double medPrice = 0;
if ( Bars.CurrentBar > 5 ) medPrice = ( Bars.Close[5] + Bars.CloseValue ) / 2;

If current bar number more than 5 calculate median price between close 5 bars ago and current bar close.

  • Current calculation bar status: the Status property,for example:
if ( Bars.Status == EBarState.Close ) { /*check if we calculating on bar close */ }
  • Indicators of the last calculation bar and the last session bar, properties LastBarOnCharts, LastBarInSession, for example:
if (Bars.LastBarOnChart) plot1.Set(Bars.CloseValue); {/*start plotting close value of bars since last bar */}

Properties of the Data Series, which a study is applied to

Attributes of Symbol, which the data series was built on, are available through the following property:

IInstrumentSettings Info { get; }

Instrument properties:

  • MTPA_MCSymbolInfo2 ASymbolInfo2 { get; }
  • string Name { get; } - Instrument name, for example, ESU3, EUR/USD;
  • string DataFeed { get; } - Data source, for example, CQG, eSignal;
  • string Description { get; } - Instrument description in words, for example, for ESU3 "S&P 500 E-mini Futures Sep13";
  • ESymbolCategory Category { get; } - Value from the list of categories, for example, futures, Forex or stock;
  • string Exchange { get; } - Exchange, where the instrument is trading;
  • double PriceScale { get; } - Instrument price scale, for example, for ES=1/100 ;
  • double PointValue { get; } - Nominal value for one point for the instrument, for example, for ES=0.01;
  • double BigPointValue { get; } - Profit/loss money equivalent in the instrument currency, when the price moves by one minimum increment, for example, for ES = 50 ;
  • double MinMove { get; } - Minimum quantity of points, when the price moves by one minimum increment, for example, for ES = 25;
  • Resolution Resolution { get; } - For example, for created ES 5 of minute chart, Resolution.ChartType = ChartType.Regular; Resolution.Type = EResolution.Minute; Resolution.Size = 5;
  • double DailyLimit { get; } - Maximum price movement allowed during a session (currently is not used in MultiCharts .NET);
  • DateTime Expiration { get; } - Expiration date of the instrument (for futures), for example, ESU3 09/19/2013;
  • RequestTimeZone TimeZone { get; } - Local, Exchange or GMT;
  • RequestQuoteField QuoteField { get; } - Ask, Bid, or Trade ;
  • string SessionName { get; } - Session name (Check or add, or change session settings in QuoteManager) ;
  • double StrikePrice { get; } - For options;
  • OptionType OptionType { get; } - For options, Put or Call;
  • DataRequest Request { get; } - Request information, by which the symbol was built;


When a study is applied to the chart or scanner, if the data source supports subscription to the status line data its data will be available from the study through the StatusLine property of the IInstrument interface. StatusLine itself provides the following information:

a) the Ask and Bid read-only properties– return current Ask, Bid

b) the Time read-only property – returns snapshot time of the status line

c) Open, High, Low, Close read-only properties – return open, high, low, close of the current day (current trade session, depending on the data source)

d) the Last read-only property – returns the last price for the instrument;

e) the PrevClose read-only property – returns the close price of the previous day (session);

f) the TotalVolume and DailyVolume read-only properties – return corresponding volumes of the status line;

g) the OpenInt read-only property – returns open interest.

Random Data Access

Starting from the initialization stage, the user gets access to all the data series that are used for calculation. It can be done by executing the FullSymbolData property of the IInstrument interface.

Example. Let’s make the average price calculation of the whole data series on the initialization stage of the indicator and display the result during the calculation:

using System;
namespace PowerLanguage.Indicator
    public class ___test : IndicatorObject
        private IPlotObject Plot1;
        public ___test(object ctx)
            : base(ctx)
            m_chartAvgPrice = 0;
        private double m_chartAvgPrice;
        protected override void Create()
            Plot1 = AddPlot(new PlotAttributes("Test"));
        protected override void StartCalc()
            int totalBars = Bars.FullSymbolData.Count;
            double totalPrice = 0;
            for (int idx = 0; idx < totalBars; idx++)
                totalPrice += Bars.FullSymbolData.Close[-idx];
            m_chartAvgPrice = totalPrice / totalBars;
        protected override void CalcBar()
            Plot1.Set(0, m_chartAvgPrice);

Please note that bar indexation is executed, starting from the current bar, leftwards with positive indices, and rightwards with negative ones.