Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Phantom trade

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

    Phantom trade

    Hello,

    I am working with a programmer developing an automated trading strategy. I am having problems testing the strategy. Every time I try to do a backtest I get a phantom trade and it ruins the backtest.

    I have tried running 2 different weeks on 2 different contract months and it happens every single time on both. I have tried 100X 300X and 500X. I have tried different parameters on both weeks and contractes and speeds. No matter what I try I get the phantom trade. My programmer does not get this trade when he runs the same backtest.

    I have been trying to test the strategy with a DX backtest. Every single time I get a trade of about 12000 points for a loss that doesn't exist. The buy is 12000 points higher than what the price is then an instant sell at the proper price at the time. It always happens when trading resumes in the afternoon at 1900 central time. Sometimes I can back the strategy up and run through the time and everything is fine then it will happen again before I finish running through the 5 day test.

    What could possibly be happening?

    Thanks in advance
    Brian
    Attached Files

    #2
    Where is your data coming from? Who is your provider?

    Did you record it or download it from the NT market replay?

    If recorded - there is an option filter you can add for "bad trades"...
    If downloaded, umm...

    Comment


      #3
      Hello Sledge thanks for trying to assist me in this.

      My Data is from Continuum, Sorry probably spelled wrong, but NB's default data provider.

      I downloaded the data from Continuum then tried running the test on market replay.

      Pretty sure I did it correctly, I watched the NT You tube video on how to do it. Didn't seem like I could of done anything wrong.

      Regards,
      Brian

      Comment


        #4
        I don't see this bad "tick" on my market replay at that time.

        Wowsers - I see I don't even have the bad tick filter set... oops..

        Looks like you are dealing with market close and then an open 3 hours later?....

        Comment


          #5
          Sledge,

          Yes I was running the test of the strategy on DX. It Closes at 1615 and re opens at 1900 Monday -Friday.

          The part I am so confused about is it is not a bad tick. You can see the candlestick does not have a long wick or anything. This happens every single time I try to run the test. Different dates, different contracts. I would just switch instruments to try a different test but I have no idea if this is a problem with the strategy, NT, or the data.

          Regards
          Brian

          Comment


            #6
            Hello Briansstocks,

            Thank you for your note.

            Is there any logic to close the position at session close? If not, do you set ExitOnClose to True in the settings?

            Comment


              #7
              Hello Patrick,

              I am not a programmer but there should not be anything to close the position at session end. I'm pretty confident that is not the case since this only happens 1 time each week I try to test unless I back the test up and run through it again then it happens on a different date.

              Under order handling Exit on close is defaulted to False on my strategy and I do not change it.

              Regards,
              Brian

              Comment


                #8
                Hello,

                If there is no logic to control an exit when this is happening this could be the downloaded replay data that is the cause, for example if the developer has different data than you this could explain it. If they had recorded the data and you had downloaded the data as an example.

                One thing you could try would be to see if the developer can send you his replay data for this time period and you could try on your end to see if the result changes. It is hard to say exactly what is happening but it seems there may be some difference between the two machines.

                It would be best to try and work this item with the developer to see what the difference between the two machines is. If needed, you can also try removing the replay data and re downloading it which may help. If you need assistance with that please let me know.

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

                Comment


                  #9
                  Different results

                  Jesse,

                  My programmer is downloading his data from NT same as me then using market replay and we are getting different results.

                  Also he sent me the data he was using and I still got the phantom trade.

                  Attached is the difference results with the same settings and the same data.

                  Regards
                  Brian
                  Attached Files

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    This is a case where the script would need to be debugged by the developer, possibly on your machine remotely.

                    There are many ways to debug a script but all require access to the code so the developer would likely be the best resource on this item.

                    Because this is not happening on his machine and it is on yours, it would likely be needed for the programmer to remote into your machine and verify the steps you take, if everything is the same the programmer could also try to debug on your machine to find the issue.

                    You could also try a fresh install of NinjaTrader to make sure there is no version difference or other factors in your current install that may play a role in the difference. If you would like to do that, the easiest way to retain your existing data and create a temporary install would be as follows:

                    Exit the platform
                    Open your Documents folder
                    Rename NinjaTrader 7 folder to NinjaTrader 7 Current Install or something you will remember.
                    Open the control panel -> Add remove programs and un install NinjaTrader
                    Download the installer from NinjaTrader.com and re install the platform.

                    This would be a fresh install but your files are still in the renamed NinjaTrader 7 folder for use later.

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

                    Comment


                      #11
                      Jesse,

                      I have also tried these tests with the same phantom trades with 2 computers freshly formatted and updated running Win7 Ultimate. On 1 computer I uninstalled NT and reinstalled with no change in results. The Computers I am running NT on are Quad core processors with 8GB of ram so I can't image it is an issue with 2 computers.

                      Regards
                      Brian

                      Comment


                        #12
                        Hi Jesse,

                        Is it possible to have these problems because the strategy was developed and successfully tested on a 32 bit laptop, but Brian tests it on 64 bit laptops?

                        Thanks,

                        Valentin

                        Comment


                          #13
                          Hello,

                          Really the only way that would happen would be if the code is using external DLL files that are only intended for 32 bit, in that case there would be errors generated with that strategy.

                          If there are no errors being generated this is likely not a issue regarding the difference in version although you could certainly try running the 32 bit instead on a different PC to see if that can re produce the problem.

                          Have you tested this going forward in data or historically also? do the results match in those tests?

                          Also is there historical data for this instrument before the date you are viewing on market replay?

                          What could happen is that if you have X amount of historical days on the chart before starting replay, but the other pc has Y historical days on the chart. This may create a different start point of data. If the strategy is only working in realtime this should not be an issue but if it deals with historical data this could be the case.

                          A test could be to just remove all historical data for the instrument and leave only the replay data. It should only display a empty chart and build bars going forward after doing that and would give a firm start point on each PC as a test.


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

                          Comment


                            #14
                            Originally posted by NinjaTrader_Jesse View Post
                            Hello,

                            Really the only way that would happen would be if the code is using external DLL files that are only intended for 32 bit, in that case there would be errors generated with that strategy.

                            If there are no errors being generated this is likely not a issue regarding the difference in version although you could certainly try running the 32 bit instead on a different PC to see if that can reproduce the problem.

                            Have you tested this going forward in data or historically also? do the results match in those tests?

                            Also is there historical data for this instrument before the date you are viewing on market replay?

                            What could happen is that if you have X amount of historical days on the chart before starting replay, but the other pc has Y historical days on the chart. This may create a different start point of data. If the strategy is only working in realtime this should not be an issue but if it deals with historical data this could be the case.

                            A test could be to just remove all historical data for the instrument and leave only the replay data. It should only display a empty chart and build bars going forward after doing that and would give a firm start point on each PC as a test.

                            I look forward to being of further assistance.
                            The code doesn't use external DLL files, so the problem is somewhere else.

                            The strategy works on each incoming tick. It could be tested with market replay or with real time data. But sometimes positions are closed after hours or strategy waits hours before next entry, so it is easier to test it with market replay, at 500X.

                            There are different starting points, but you can see on Brian's images here:
                            http://ninjatrader.com/support/forum...58&postcount=9
                            that there are the same orders @96.835, then @96.860, and the difference is on the order @96.920. I have Enter Long / Close Position and Brian has just Exit Short. Since there are matching orders in the beginning, it seems that it is not caused by different starting points.

                            The strategy checks 5 - 6 conditions and if all they are true, new position is opened and the opposite position is closed automatically. It seems that on Brian's machine some of the conditions are false, so the order is just Exit Short.

                            OK, I will delete all historical data for the instrument.

                            Comment


                              #15
                              Originally posted by Valyo View Post
                              The code doesn't use external DLL files, so the problem is somewhere else.

                              The strategy works on each incoming tick. It could be tested with market replay or with real time data. But sometimes positions are closed after hours or strategy waits hours before next entry, so it is easier to test it with market replay, at 500X.

                              There are different starting points, but you can see on Brian's images here:
                              http://ninjatrader.com/support/forum...58&postcount=9
                              that there are the same orders @96.835, then @96.860, and the difference is on the order @96.920. I have Enter Long / Close Position and Brian has just Exit Short. Since there are matching orders in the beginning, it seems that it is not caused by different starting points.

                              The strategy checks 5 - 6 conditions and if all they are true, new position is opened and the opposite position is closed automatically. It seems that on Brian's machine some of the conditions are false, so the order is just Exit Short.

                              OK, I will delete all historical data for the instrument.
                              Are you using ADD( )? I've seen issues where the first day doesn't start until 10-10:30am on the ADDed item.

                              And are you using OnMarketData ?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              40 views
                              0 likes
                              Last Post alifarahani  
                              Started by Waxavi, Today, 02:10 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by Kaledus, Today, 01:29 PM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X