Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical 1-tick Last, Bid, Ask

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

    Historical 1-tick Last, Bid, Ask

    Hello,

    if I have several historical items Bid, Ask and Last in the same millisecond, which is executed first in the OnBarUpdate? What sort order is used?

    Thanks







    Attached Files

    #2
    If I want to build the historical delta (bid-ask), I need to assign each tick as BUY or SELL. This can only be done when I compare it with the historical currentBid and currentAsk.
    I can calculate the historical currentBid and currentAsk as will running the BarsInProgress for each of them.
    When BarsInProgress is executed for the Last then I can compare its price with the historical currentBid and currentAsk and know whether it is a trade BUY or SELL.
    It is imperative that the BarsInProgress run in the same order that the events happened in real time. If not, some trades will be misclassified (as actually happens).

    Unless I'm mistaken, it remains impossible to build accurate indicators of historical delta bid-ask in NinjaTrader8. I'm wrong ?

    Regards

    Comment


      #3
      If you're using the old approach of obtaining historical bid/ask data via AddDataSeries, it will always called OnBarUpdate in the order the data series were added (0, 1, 2, 3).

      If you need to obtain the bid/ask ticks in the true order they were processed, you need to enable the new "Tick Replay" mode, and then re-implement your indicator to use OnMarketData and obtain the values that way. This mode is guaranteed to give you the exact sequence of updates that went into building a bar.

      An overview on enabling this feature can be found here - http://ninjatrader.com/support/helpG...ick_replay.htm

      NinjaTrader 8 stores the current bid/ask price with the last price. This data is accessed via the marketDataUpdate.Bid / marketDataUpdate.Ask property. So if you want to check the current bid/ask when the last is executed, you simply do:

      Code:
      protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
      {
      	if(marketDataUpdate.MarketDataType == MarketDataType.Last)
      	{
      		Print(marketDataUpdate.Ask);
      		Print(marketDataUpdate.Bid);				
      	}
      }
      MatthewNinjaTrader Product Management

      Comment


        #4
        WOW. Amazing.
        I have just test Delta calculations with historical NT8 vs MarketReplay NT7 and the matching is very accurate (not 100% exactly but very aproximate).

        Only any questions, if possible:
        - Who provide this data ? My datafeed or NT servers ?
        - Where these data are stored ? I don't see them in Tools/Historical Data (nor Historical, nor MarketReplay).

        Thanks very much.

        Comment


          #5
          Glad to hear that mode is working for your needs so far.

          This is the tick data obtained by your provider. It is stored in the same location as your tick data. What is not shown in the historical data manager is the bid/ask field that is saved with the last price.

          I should also mention that the granularity that the tick data is time stamped depends on your data provider. We'll store the data down to the DateTime.Tick should it be provided.
          MatthewNinjaTrader Product Management

          Comment


            #6
            Based on user guide, When using a Market Replay, the series are synced by their timestamp. These timestamps are synced only to a 1-second level of tolerance.



            I would like to test up to 1ms of granularity, and be able to get bid/ask price corresponding to the bar of that millisecond.

            Is it possible? Is there any "unsupported" functionality to accomplish that?

            It seems that tick based indicators will be built little differently in real time (where they have 1ms granularity) vs historical (because of 1 sec granularity in historical). Very often we have few ticks within 1 second.

            Anyway ticket replay could be optionally synchronized up to 1 ms instead?

            Thanks

            Comment


              #7
              The quote in the help guide on using historical bid/ask series is out of date. I will have that corrected, thank you.

              The tick data in NinjaTrader 8 stamped down to 100 nanosecond resolution should your provider support it. This allowed us to get over the limitations of ticks building differently historically vs real-time.

              Just so we're on the same page, Tick Replay is a new feature in NinjaTrader 8 and is NOT the same thing as Market Replay.
              MatthewNinjaTrader Product Management

              Comment


                #8
                Cannot get bid ask data for indicator instantiated programatically

                The performance is excellent for bid ask indicators using OnMarketData, added directly to a chart with a tick replay price series.

                But if, in a different indicator, I create an instance of the first indicator, I won't get any bid ask historical results from that instance, because the new price series that the instance gets its data from will not run in tick replay. And, as you've explained, I cannot get the correct bid and ask from Add()ed 1 tick bid, ask and last series.

                Can there be an option for programatically instantiated indicators to run in tick replay mode?

                Comment


                  #9
                  Hello,

                  I'm not seeing this behavior on my end in my test. Are you making sure to enable Tick Replay on your data series and use Calculate.OnEachTick in your hosting indicator? If so,can you please share a code snippet that shows this issue occurring? Here is the code I'm using, which is successfully printing different values numerous times within each historical bar:

                  Code:
                  protected override void OnBarUpdate()
                  		{
                              if (CurrentBar < 1) return;
                  
                              if (sma != null) Print(String.Format("{0}: sma = {1}", CurrentBar, SMA(14)[0]));
                  		}
                  Last edited by NinjaTrader_DaveI; 10-01-2015, 04:11 PM.
                  Dave I.NinjaTrader Product Management

                  Comment


                    #10
                    Dave,

                    I made some simple test indicators to send you.

                    But I was surprised, and happy to find that what I was trying to do does indeed work. Thanks for taking a look at this.

                    Update2: As of October 9 all working great.,
                    Ricam
                    Last edited by Ricam; 10-10-2015, 09:54 AM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Perr0Grande, Today, 08:16 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post Perr0Grande  
                    Started by elderan, Today, 08:03 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post elderan
                    by elderan
                     
                    Started by algospoke, Today, 06:40 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post algospoke  
                    Started by maybeimnotrader, Today, 05:46 PM
                    0 responses
                    12 views
                    0 likes
                    Last Post maybeimnotrader  
                    Started by quantismo, Today, 05:13 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post quantismo  
                    Working...
                    X