Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strange bug in NT

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

    Strange bug in NT

    I use NT 6.5.1000.8. I made simple strategy:
    1) CalculateOnBarClose = false;
    2) In OnBarUpdate() I write Time[0]...Close[0] into file stream.
    I run my strategy with ES (march) 1 tick.
    I found the strange bug in NT. Description:
    1) I start my strategy first time. It writes data into file.txt
    2) I rename the file.txt to file1.txt
    3) I start my strategy second time. It writes data into file.txt
    4) I rename the file.txt to file2.txt
    When I compare those two .txt files with diff utility I can see that in file1.txt there is no data for approx. 1 min before I started it. This data is present in file2.txt, but not in file1.txt. So, I can figure out that NT pushes history except last minute.

    I tried this several times, but got the same result

    Here is the screenshot (can't upload it to this forum): http://depositfiles.com/files/p7xk2uahn

    #2
    PS. I use AMP zenfire realtime simulator.

    Comment


      #3
      Hello,

      I will look into this and get back to you as soon as I have more information.
      DenNinjaTrader Customer Service

      Comment


        #4
        Hello,

        Provided you are running on the same chart with the same set of data available you will have the same prints. If you are starting your strategy on a new chart it may differ like what you are experiencing.
        DenNinjaTrader Customer Service

        Comment


          #5
          I use strategy tab in Control Center. No other windows are open. The problem is that data is skipped, not differs.
          For example, imagine that complete data is: "1,2,3,4,5,6,7,8,9,10". I run the strategy when "1,2,3,4" is historical data (let's assume). I recieve in OnBarClose(): "1,2,3,4,7,8,9,10" where "7,8,9,10" is realtime. "5,6" is missed. If I run the strategy when "1,2,3,4,5,6" is historical, I recieve "1,2,3,4,5,6,9,10". Where "9,10" is realtime data. "7,8" skipped.
          Please help and let me know if you need more information from me. Were you able to repeat the bug?

          Comment


            #6
            zer0balance,

            You may be running into a current limitation, but I am not sure if it is the same case. If you could upload an as-simple-as-possible sample of your strategy that demonstrates what you are seeing then we could test on our end. Please provide exact reproduction steps as well. Thank you.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Archive (screen shot of diff programm + strategy src): http://depositfiles.com/files/wx5pktflb
              Instructions:
              1) NT 6.5.1000.8 from ninjatrader.com
              2) Real-time demo account from http://www.ampfutures.com (you can try to catch this on your datafeed)
              3) Open NT with no windows except control center and go to strategies tab
              4) New strategy, select attached strategy, ES 03-09, 1 tick.
              5) Start strategy, wait for 15-20 seconds, stop strategy, remove strategy
              6) Now, locate in current directory (NT install dir) file histbug.txt and rename it to histbug1.txt
              7) New strategy, select attached strategy, ES 03-09, 1 tick.
              8) Start strategy, wait for 15-20 seconds, stop strategy, remove strategy
              9) Now, locate in current directory (NT install dir) file histbug.txt and rename it to histbug2.txt
              10) Get diff tool. I use TortoiseMerge from http://tortoisesvn.net
              11) Compare histbug2.txt and histbug1.txt. You should see that in histbug1.txt skipped some data that is presend in histbug2.txt.

              Please let me know.

              Code:
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Using declarations[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] System;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] System.IO;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] System.ComponentModel;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] System.Diagnostics;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] System.Drawing;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] System.Drawing.Drawing2D;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] System.Xml.Serialization;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Cbi;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Data;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Indicator;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Gui.Chart;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Strategy;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#008000]// This namespace holds all strategies and is required. Do not change it.[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Strategy[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] histbug[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][Description([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"histbug"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] histbug : Strategy[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Variables[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#008000]// Wizard generated variables[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#008000]// User defined variables (add any user defined variables below)[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2]StreamWriter sw;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] initialized;[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] This method is used to configure the strategy and is called once before any strategy method is called.[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
              [SIZE=2][FONT=Courier New]initialized=[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] Called on each bar update event (incoming tick)[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](!initialized) {[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]initialized=[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](sw==[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]sw = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] StreamWriter([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"histbug.txt"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](sw!=[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) {[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]sw.WriteLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"{0},{1},{2},{3},{4},{5}"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].ToString(),Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].ToString(),High[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].ToString(),Low[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].ToString(),Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].ToString(),Volume[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].ToString());[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
               
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Dispose() [/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](sw!=[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) {[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]sw.Close();[/FONT][/SIZE]
              [SIZE=2][FONT=Courier New]sw.Dispose();[/FONT][/SIZE]
              [SIZE=2][FONT=Courier New]sw=[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]base[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2].Dispose(); [/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Properties[/SIZE][/FONT]
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE][/FONT]
              [FONT=Courier New][SIZE=2]}[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]

              Comment


                #8
                Thank you zer0balance. This is indeed the limitation in NT6.5 that we are aware of.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  Thank you zer0balance. This is indeed the limitation in NT6.5 that we are aware of.
                  Could you please explain this limitation. I don't have any information about this. Will it be fixed? And how can I wouk it out.

                  Comment


                    #10
                    zer0balance,

                    The limitation is going from historical to live. You may "miss" some ticks as the strategy transitions. If you do not care for this transition I suggest you just run with "if (Historical) return;" then it will not influence you at all.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Josh thanks for explanation! I do care for this, that's why I would like to resolve this problem so much.
                      1) Could you please advise any (is there any?) method, so those ticks were not missed ? Some workaround...
                      2) Is this behavior only in 6.5?
                      2) Are you going to fix this in near future?

                      Comment


                        #12
                        zer0balance,

                        What is your requirement for such a transition? Any automated trading strategy should have very little trouble by this. Just run the strategy before the market opens. You may miss a little at the transition, but that is it, a one time loss. If you never shut off your strategy you will never have problems again. It is only really noticeable on the 1 tick time frame. We are aware of this and are working to improve it. There are no workaround.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you very much! 0 tick loss in transition is perefect! =)
                          BTW, found this bug with posted strategy above:
                          1) Open NT
                          2) Connect
                          3) Run strategy
                          4) Disconnect
                          5) Connect
                          6) Run strategy
                          Error on calling 'OnBarUpdate' method for strategy 'histbug': The process cannot access the file 'C:\Program Files\NinjaTrader 6.5\bin\histbug.txt' because it is being used by another process.
                          It is because Dispose method is not called when Disconnect.

                          Comment


                            #14
                            Thank you for bringing this to our attention. We will look into it.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              This is a bug which will be fixed with next update. Thanks for reporting.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              646 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              367 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              107 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              569 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X