MarketData


Summary

Provide access to charts data (bars and ticks) and to the Depth of Market data.

Syntax

public interface MarketData

Members

NameTypeSummary
GetBars MethodGets the bars for the specific timeframe.
GetBarsAsync MethodThe asynchronous method to get the bars for the specific timeframe for the specific symbol.
GetMarketDepth MethodGets the Depth of Market for the specific symbol.
GetTicks MethodGets the Tick data.
GetTicksAsync MethodThe asynchronous method to get tick data.

Example 1

MarketDepth md = MarketData.GetMarketDepth(Symbol);

Example 2

using cAlgo.API;
using cAlgo.API.Internals;
namespace cAlgo
{
    // This sample indicator shows how to get a symbol and time frame market data
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MarketDataSample : Indicator
    {
        private Bars _bars;
        private Ticks _ticks;
        private MarketDepth _marketDepth;
        [Parameter("Use Current Symbol", DefaultValue = true)]
        public bool UseCurrentSymbol { get; set; }
        [Parameter("Other Symbol Name", DefaultValue = "GBPUSD")]
        public string OtherSymbolName { get; set; }
        [Parameter("Use Current TimeFrame", DefaultValue = true)]
        public bool UseCurrentTimeFrame { get; set; }
        [Parameter("Other TimeFrame", DefaultValue = "Daily")]
        public TimeFrame OtherTimeFrame { get; set; }
        protected override void Initialize()
        {
            var symbol = UseCurrentSymbol ? Symbol : Symbols.GetSymbol(OtherSymbolName);
            var timeframe = UseCurrentTimeFrame ? TimeFrame : OtherTimeFrame;
            // You can use GetBarsAsync instead of GetBars
            _bars = MarketData.GetBars(timeframe, symbol.Name);
            // You can use GetTicksAsync instead of GetTicks
            _ticks = MarketData.GetTicks(symbol.Name);
            _marketDepth = MarketData.GetMarketDepth(symbol.Name);
        }
        public override void Calculate(int index)
        {
        }
    }
}
Reference