• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get time stamp of ticks during tick replay?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    How to get time stamp of ticks during tick replay?

    I have an indicator set up to use tick replay as described at https://ninjatrader.com/support/help...ata_series.htm

    I can't figure out how to get the ticks that are sent to OnBarUpdate() to reflect the time of the individual tick as opposed to the time of the start of the bar.

    You can get volume and price information for the tick, but not the time.

    I'm attaching the sample code I'm using. This is for a chart with tick replay enabled, with a few dozen bars of 5 tick data. It prints things like this:

    CurrentBar=0 Close[0]=45.42 Time[0]=636041440813630000
    CurrentBar=0 Close[0]=45.41 Time[0]=636041440813630000
    CurrentBar=0 Close[0]=45.41 Time[0]=636041440813630000
    CurrentBar=0 Close[0]=45.41 Time[0]=636041440813630000
    CurrentBar=0 Close[0]=45.41 Time[0]=636041440813630000

    CurrentBar=1 Close[0]=45.41 Time[0]=636041440813660000
    CurrentBar=1 Close[0]=45.41 Time[0]=636041440813660000
    CurrentBar=1 Close[0]=45.41 Time[0]=636041440813660000
    CurrentBar=1 Close[0]=45.42 Time[0]=636041440813660000
    CurrentBar=1 Close[0]=45.41 Time[0]=636041440813660000

    CurrentBar=2 Close[0]=45.42 Time[0]=636041440893080000
    CurrentBar=2 Close[0]=45.42 Time[0]=636041440893080000
    CurrentBar=2 Close[0]=45.42 Time[0]=636041440893080000
    CurrentBar=2 Close[0]=45.42 Time[0]=636041440893080000
    CurrentBar=2 Close[0]=45.42 Time[0]=636041440893080000

    CurrentBar=3 Close[0]=45.42 Time[0]=636041440924000000
    CurrentBar=3 Close[0]=45.42 Time[0]=636041440924000000
    CurrentBar=3 Close[0]=45.42 Time[0]=636041440924000000
    CurrentBar=3 Close[0]=45.42 Time[0]=636041440924000000
    CurrentBar=3 Close[0]=45.42 Time[0]=636041440924000000

    As you can see the times are only updated at the start of the bar, and never within the bar at the tick level.

    Is there any way to do this? I think the correct timestamps are available to BarType in OnDataPoint() but I don't see a way to get that passed on to the indicator.

    Here's the code I used:

    Code:
    #region Using declarations
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class TickReplayTimes : Indicator
        {
            protected override void OnStateChange()
            {
                if(State==State.SetDefaults)
                {
                    [email protected]"Enter the description for your new custom Indicator here.";
                    Name="TickReplayTimes";
                    Calculate=Calculate.OnEachTick;
                    IsOverlay=false;
                    DisplayInDataBox=true;
                    DrawOnPricePanel=true;
                    DrawHorizontalGridLines=true;
                    DrawVerticalGridLines=true;
                    PaintPriceMarkers=true;
                    ScaleJustification=NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive=true;
                }
                else if(State==State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                Print("CurrentBar="+CurrentBar+" Close[0]="+Close[0]+" Time[0]="+Time[0].Ticks);
            }
        }
    }
    Last edited by meinl; 07-15-2016, 01:35 AM.

    #2
    Hello,

    Thank you for the post.

    The Time[0] object will always reflect the Primary series last closed or building bar, in this case the building bar. Because you are using OnEachTick, you are seeing each tick event but printing the Primary series bar time.

    For TickReplay specifically, There is a document with some samples here: http://ninjatrader.com/support/helpG...sub=tickreplay

    If you are trying to get the Ask and bid data for Tick replay the samples would be how, if you are only trying to print each individual ticks time from OnBarUpdate, you could instead add a 1 tick series to the script and use the BarsInProgress index to delegate logic.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks, using marketDataUpdate.Time.Ticks was what I needed.
      Last edited by meinl; 07-15-2016, 02:52 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ct, Today, 05:31 AM
      0 responses
      1 view
      0 likes
      Last Post ct
      by ct
       
      Started by pstrusi, Today, 02:21 AM
      0 responses
      5 views
      0 likes
      Last Post pstrusi
      by pstrusi
       
      Started by indy73, Yesterday, 10:52 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by priceisking, 05-13-2019, 08:30 AM
      6 responses
      40 views
      0 likes
      Last Post Harry
      by Harry
       
      Started by WgfhqDsdfg, Today, 12:56 AM
      0 responses
      7 views
      0 likes
      Last Post WgfhqDsdfg  
      Working...
      X