Realtime time and sales

ff22

Junior member
Messages
13
Likes
0
Hi do anyone know which platform can analyze realtime time and sales data? Can Tradestation handle it? (As I researched it seems Metastock can't do that) And in case I have to end up using Excel, which data feed will work? (say IB, eSignal?) Many thanks for help :smart:
 
Tradestation has a time & sales object & a related update event but it's fairly useless as it is not synchronised with current bid/ask data.

Ninja has time & sales event (onMarketData) and it is synched to bid & ask so this is your best bet.

Note that both Ninja & Tradestation only timestamp ticks to the second but you can have millisecond timers on your PC to analyze when they come to you.
 
Tradestation has a time & sales object & a related update event but it's fairly useless as it is not synchronised with current bid/ask data.

Ninja has time & sales event (onMarketData) and it is synched to bid & ask so this is your best bet.

Note that both Ninja & Tradestation only timestamp ticks to the second but you can have millisecond timers on your PC to analyze when they come to you.


Thanks a lot for your answer. In fact the major information I need is like this
"20K(Volume)@19.2(Price) At Bid/Ask" something like this, so that I can develop an indicator based on these data. I did look at IB's time and sales data and they got the sychronized bid/ask data too, but it seems their data aren't too reliable...

I haven't got much experience on Ninja actually. Do you think Amibroker can handle the same thing?
 
Tradestation can't do it. Ninja can. No idea about Amibroker

I start exploring ninjascript now. Seems that one should get the data from OnMarketData, but I just know how to print the info as output. How can one manipulate further on those data? Manu thanks for your help.(y)
 
Yup - OnMarketData is right...

Code:
protected override void OnMarketData(MarketDataEventArgs e) {
if (e.MarketData.Ask == null || e.MarketData.Bid == null)
                return;
			
if (e.MarketDataType == MarketDataType.Ask) {
// This event triggered on inside ask change
	insideAsk = e.Price;
	}
else if (e.MarketDataType == MarketDataType.Bid) {
// This event triggered on inside bid change
	insideBid = e.Price;
	}
else if (e.MarketDataType == MarketDataType.Last) {
// This event triggered when a trade occurs
Print("Bid " + insideBid.ToString() + " Ask " + insideAsk.ToString() + " Trade Price " + e.Price.ToString() + " Trade Qty " + e.Volume.ToString;
 
Yup - OnMarketData is right...

Code:
protected override void OnMarketData(MarketDataEventArgs e) {
if (e.MarketData.Ask == null || e.MarketData.Bid == null)
                return;
			
if (e.MarketDataType == MarketDataType.Ask) {
// This event triggered on inside ask change
	insideAsk = e.Price;
	}
else if (e.MarketDataType == MarketDataType.Bid) {
// This event triggered on inside bid change
	insideBid = e.Price;
	}
else if (e.MarketDataType == MarketDataType.Last) {
// This event triggered when a trade occurs
Print("Bid " + insideBid.ToString() + " Ask " + insideAsk.ToString() + " Trade Price " + e.Price.ToString() + " Trade Qty " + e.Volume.ToString;



Thanks so much! It is really amazing that you come up with the script so quickly. Guess it may take a day for me to write something like this :innocent:



My idea is to smoothen the sales data, say I sum up the total volume of initiative buy (sales at Ask price) in one minute, etc. I guess i should focus on"MarketData.Last.Price", "MarketData.Last.Volume", Right?

I just wonder how you can subsequently write an indicator/formula after you get the data from OnMarketData. (So far it seems it's just displaying the data in the output windows using ".print") Please correct me if I get it wrong. I'm really a newbie in it :smart:
 
I have a cumulative delta indicator if you are interested... It was one of the first Ninja Scripts I wrote.

Code is here - it'll put a histogram below the chart showing the cumulative delta. Based on this code, you should be able to do other delta type stuff with slight alterations.

Note that this only works in real time with real time data.

Any problems - feel free to ask...

Code:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Cumulative Delta of Buys/Sells
    /// </summary>
    [Description("Cumulative Delta of Buys/Sells")]
    public class DTCDelta : Indicator
    {
        #region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)
		private int CDelta = 0;
		private int LastBar = 0;
		private double lastPrice = 0;
		private double askPrice = 0;
		private double bidPrice = 0;
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Bar, "DeltaPositive"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Bar, "DeltaNegative"));
            Add(new Line(Color.FromKnownColor(KnownColor.FloralWhite), 0, "ZeroLine"));
            Overlay				= false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
			if (CDelta > 0) 
			{
				DeltaPositive.Set(CDelta);
			}
			else
			{
				DeltaNegative.Set(CDelta);
			}
        }
		// Called on each tick
		protected override void OnMarketData(MarketDataEventArgs e) 
		{ 
			// Print some data to the Output window 
			if (e.MarketDataType == MarketDataType.Last)
			{	
				lastPrice = e.Price;
				if ((lastPrice >= askPrice) && (lastPrice > bidPrice))
				{
					CDelta += (int) e.Volume;
				}
				else if ((lastPrice <= bidPrice) && (lastPrice < askPrice))
				{
					CDelta -= (int) e.Volume;
				}
				
				else // neutrals are too insignificant to waste ram space and processing power, just return
					return;	
			}
			else if (e.MarketDataType == MarketDataType.Ask)
				askPrice = e.Price;
			
			else if (e.MarketDataType == MarketDataType.Bid)
				bidPrice = e.Price;
		}
        #region Properties
        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries DeltaPositive
        {
            get { return Values[0]; }
        }

        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries DeltaNegative
        {
            get { return Values[1]; }
        }

        #endregion
    }
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    public partial class Indicator : IndicatorBase
    {
        private DTCDelta[] cacheDTCDelta = null;

        private static DTCDelta checkDTCDelta = new DTCDelta();

        /// <summary>
        /// Cumulative Delta of Buys/Sells
        /// </summary>
        /// <returns></returns>
        public DTCDelta DTCDelta()
        {
            return DTCDelta(Input);
        }

        /// <summary>
        /// Cumulative Delta of Buys/Sells
        /// </summary>
        /// <returns></returns>
        public DTCDelta DTCDelta(Data.IDataSeries input)
        {
            if (cacheDTCDelta != null)
                for (int idx = 0; idx < cacheDTCDelta.Length; idx++)
                    if (cacheDTCDelta[idx].EqualsInput(input))
                        return cacheDTCDelta[idx];

            lock (checkDTCDelta)
            {
                if (cacheDTCDelta != null)
                    for (int idx = 0; idx < cacheDTCDelta.Length; idx++)
                        if (cacheDTCDelta[idx].EqualsInput(input))
                            return cacheDTCDelta[idx];

                DTCDelta indicator = new DTCDelta();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                Indicators.Add(indicator);
                indicator.SetUp();

                DTCDelta[] tmp = new DTCDelta[cacheDTCDelta == null ? 1 : cacheDTCDelta.Length + 1];
                if (cacheDTCDelta != null)
                    cacheDTCDelta.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheDTCDelta = tmp;
                return indicator;
            }
        }
    }
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
    public partial class Column : ColumnBase
    {
        /// <summary>
        /// Cumulative Delta of Buys/Sells
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.DTCDelta DTCDelta()
        {
            return _indicator.DTCDelta(Input);
        }

        /// <summary>
        /// Cumulative Delta of Buys/Sells
        /// </summary>
        /// <returns></returns>
        public Indicator.DTCDelta DTCDelta(Data.IDataSeries input)
        {
            return _indicator.DTCDelta(input);
        }
    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public partial class Strategy : StrategyBase
    {
        /// <summary>
        /// Cumulative Delta of Buys/Sells
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.DTCDelta DTCDelta()
        {
            return _indicator.DTCDelta(Input);
        }

        /// <summary>
        /// Cumulative Delta of Buys/Sells
        /// </summary>
        /// <returns></returns>
        public Indicator.DTCDelta DTCDelta(Data.IDataSeries input)
        {
            if (InInitialize && input == null)
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

            return _indicator.DTCDelta(input);
        }
    }
}
#endregion
 
Top