Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Last tick of bar

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

    Last tick of bar

    I have a script that works with Tick data as DataSeries1 and with 5 minute data which is the main dataseries of the script.
    It does some calculation every time a tick data is received (BarsInProgress==1) and shows the result and does a reset in the calculation at the close of the bar (BarsInProgress==0) (CalculateOnBarClose is set to true). The issue is that the last tick of the current bar of dataseries 0 is received after triggering the event close of the bar. So the data of the last tick is always added to the next bar of the dataseries 0. I don't know how to solve this issue because I don't understand why I receive the last tick of the current bar after receiving the trip of BarsInProgress==0.

    Thanks for the help

    #2
    Hello bonnies,

    Thanks for opening the thread.

    The tick will have to iterate through to create the bar, which is why you are seeing the last tick appear after the close of a bar.

    Attached is an example that demonstrates how to build a primary bar with tick data. It can be used to observe how ticks and bar formations can be synchronized.

    Please let me know if I can be of further help.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you for your suggestion Jim. I have tried the strategy showed at the example script in my own script but I still have issues between the tick calculation and the minutes bar.
      So I tried to plot on the chart the "tickBuiltVolumeSeries" dataseries of the example. So the only thing I did to the example script is add a new plot :
      Add(new Plot(Color.FromKnownColor(KnownColor.Chocolate), PlotStyle.Line, "Plot2"));
      at the Initialize();
      and plot the "volumeCollect" adding this line of code after this one:

      tickBuiltCloseSeries.Set(Closes[1][1]);
      // set the collected volume
      tickBuiltVolumeSeries.Set(volumeCollect);

      So, doing this I should get the total volume of the tick bar at the close of the minute bar. So I plot this and also the "Vol" indicator which comes with Ninjatrader. And both should get the same volume.
      But I have seen that they show the same volume sometimes at some bars but not in all of them. Some differ in 1 or 2 contracts but some other differ much more. I attached some pictures with some examples of some bars. There is quite difference. So this is not solving the issue of synchro.
      I attach to pictures of each time bar. The pictures ending with "_a" are pictures showing real time values. And the pictures ending with "_b" are the same pictures but with history values. As you will see with history values both indicators match. But in real time they don't match.

      Can you provide further assistance Jim, please?
      In my indicator I am trying to show the volume at each level of price at the minute time bar. And because of this issue I see some volume difference at the open and the close levels of the minute bars.
      Attached Files
      Last edited by bonnies; 06-14-2017, 10:31 AM.

      Comment


        #4
        Next attached files.
        Attached Files

        Comment


          #5
          Hello bonnies,

          Thanks for your note.

          The sample was designed for historical data and would not be a viable solution for real time data.

          I'll take some time to work on and improve this sample. I will not be able to provide an ETA on when I will have an improved sample ready, but I will update this post when I am done making modifications.

          If you find a solution before I do, please feel free to update the thread.
          JimNinjaTrader Customer Service

          Comment


            #6
            Thak you for your effort Jim.
            I don't think I will be able to find a solution because I have been woriking on this issue for weeks. And when I ran out of ideas I decided to ask for help here at the support forum.
            I will wait for your news.

            Thank you

            Comment


              #7
              The tick will have to iterate through to create the bar.
              192.168 ll

              Comment


                #8
                Hello everyone,

                We spent sometime looking at this together and eventually consulted the development team. They have determined there to be corner case issue with syncing data series which would prevent the ability to construct an identical DataSeries based on tick data of a secondary series.

                Allowing the bar to tick through would be the proper way which works for historical but may hiccup and de-sync when transitioning to Realtime.

                This issue is being tracked for NinjaTrader 8 with ticket ID NTEIGHT-11966. As NinjaTrader 7 is in a freeze, the issue will be left as-is in NinjaTrader 7.

                When the fix for this case is included in a release of NinjaTrader 8, the ticket ID can be noted in the Release Notes page of the help guide found here: https://ninjatrader.com/support/help...ease_notes.htm

                Thanks for your patience while we looked into this further.
                Last edited by NinjaTrader_Jim; 08-22-2017, 09:56 AM.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Was there ever a fix for this? Using Order Flow Cumulative Delta with any bar series has the same issue.

                  Comment


                    #10
                    Hello Lance El Camino,

                    The fix was applied in NinjaTrader 8 Release 9.

                    Are you using the correct code additions to add the single tick data series for that instrument, and update the indicator using that added tick series?

                    https://ninjatrader.com/support/help...ive_delta2.htm

                    If you are still having issue, could you attach a small example showing how you have set up the indicator in your original script, and also a screenshot of the Data Series settings used for your test?
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks for the quick response. I was wrong and I failed to mention I was using Volume bars so as stated in the help guide:

                      "Volume bars could split a single tick into multiple bars for both historical and real-time data. As such Order Flow Cumulative Delta could run into tracking limitations on the internally added 1 tick series, as all the volume would be processed on the first 1 tick bar / delta calculation."



                      An easy workaround could be to add a condition using Volume Counter or VOL where a minimum amount of volume has occurred first so the last tick from the previous bar won't be considered when the new bar forms.

                      Comment


                        #12
                        I have another question. I've added 2 data series :

                        AddDataSeries("^TICK", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Last);
                        AddDataSeries(Data.BarsPeriodType.Tick, 1);

                        How can I use IsFirstTickOfBar on only the TICK data series?

                        Comment


                          #13
                          Hello Lance El Camino,

                          You can use BarsInProgress to determine which data series is updating, and then you can check IsFirstTickOfBar for that particular data series.

                          Note that this will not be meaningful on a single tick data series. We would recommend checking IsFirstTickOfBar on a "main" data series. (The main data series that is used in the indicator, not the single tick data series)

                          Code:
                          if (BarsInProgress == 0) // The main data series we would check
                          {
                            if (IsFirstTickOFBar)
                            {
                          
                            }
                          }
                          JimNinjaTrader Customer Service

                          Comment


                            #14
                            Oh yeah, thanks!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by aa731, Today, 02:54 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post aa731
                            by aa731
                             
                            Started by thanajo, 05-04-2021, 02:11 AM
                            3 responses
                            470 views
                            0 likes
                            Last Post tradingnasdaqprueba  
                            Started by Christopher_R, Today, 12:29 AM
                            0 responses
                            10 views
                            0 likes
                            Last Post Christopher_R  
                            Started by sidlercom80, 10-28-2023, 08:49 AM
                            166 responses
                            2,237 views
                            0 likes
                            Last Post sidlercom80  
                            Started by thread, Yesterday, 11:58 PM
                            0 responses
                            4 views
                            0 likes
                            Last Post thread
                            by thread
                             
                            Working...
                            X