Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Extra trade executions in strategy

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

    Extra trade executions in strategy

    I have a strategy I run in simulation and the same strategy and parameters I run to my brokerage. I suddenly noticed some extra trades in the strategy historical performance for the simulated account instance. I checked the executions and saw a 2L for the position for one "execution". Well the strategy parameters are set for 1 contract quantity, and max 1 entries per direction. So there was no way I could have 2 contracts long at the same time. Also, the chart only displays the correct legitimate trades, not the "fake" ones.

    Then I created a new chart, with the same strategy to start from scratch. This one looked correct, ie it never had more than 1L or 1S. Finally, I did the same thing for the strategy that is running live to my brokerage. I created a new instance in the strategy tab. But it has the "2L" entries, even the clean new instance. If I go to the brokerage account there never were multi-contract entries in live trading. So I have two questions:
    1) How do I get rid of these erroneous "fake" trades?
    2) Related question is why does this happen?

    One other fact is that I aborted a trade in the middle of operation last friday. In other words, the strategy had opened a position and I manually exited it, which disables the strategy at the same time. Still, this is supposed to give the backtested values for the strategy, not every action in the IB account. Even if I had 2 contracts in the IB, which I never did, it should show the strategy results not account results.

    I did one final test. I disabled the new chart strategy that was working (had only 1L or 1S) and changed to the IB brokerage account. It also worked and had only 1 contract in any one trade. So what is going on?
    Last edited by tradetree; 04-10-2011, 10:17 PM.

    #2
    Hi tradetree, so you're saying the historical backtest performance you get for your custom strategy depend on the account it's being set to execute to?

    I don't remember are you working on R4 currently?

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I have symptoms of bad historical back-testing, but I don't know what events cause it. Right now I have two charts with the same instrument and time-frame, and number of days loaded, and same session template. I also have the same strategy enabled in both charts, with the same parameters. I keep going through the parameter settings to find a difference, but can't find one that matters. Yet the two charts and enabled strategies have different back-test "performance" results.

      So to answer your question, at one point I thought it would change with the account that was selected, but that is not true. I can change to any account and I get the same bad back-test results. Not only that, but the chart is not even displaying the bad back-test trades, only the good ones. I know this sounds like I'm doing something wrong, and I keep looking for what I could be doing but can't find anything. I rebooted my computer, thinking it would just go away and it did not.

      I am using release 4, multi-broker live. Keep in mind that I usually see these strange events (in general) when I start connecting to IB again. For a few weeks I didn't use the IB connection, but now I'm trading live using it.



      Originally posted by NinjaTrader_Bertrand View Post
      Hi tradetree, so you're saying the historical backtest performance you get for your custom strategy depend on the account it's being set to execute to?

      I don't remember are you working on R4 currently?

      Thanks,

      Comment


        #4
        Thanks for the clarifications tradetree - you would then need to slowly iron out any variables that could effect this outcome to see where the issue is found - for example you mention IB - if you disconnect and for example connect to another connection (perhaps even External Feed) and then reload the NinjaScripts applied on both charts: do the discrepancies stay? Do both strategies use the same BarsRequired amount and chart series setup and also importantly fill algorithm? If you have a spare PC it would of course be interesting to know if you could reproduce at will then also there with your custom script...
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I did some testing and there has to be an issue with NT. It just is a question of how some of the internals of NT store trades and handle the database of trades. So at best, there is a corruption of a trading database due to an NT bug, or else there is an active NT bug. In other words, perhaps clearing some sort of database may clear the condition. It then may not be necessary to resolve the actual bug in NT that caused the corruption as it doesn't happen very often.

          In either case, I need some assistance greater than asking me to isolate it further. This is what I found:
          1) The "order ID" under Executions changes for "phantom" trades. Normal trades are "NT-00826, NT-00827". Bad trades are "634550376, 634550377". There are only 5 or 6 bad trades in the whole sequence.
          2) The time of execution of normal trades are on a bar boundary. This is a two minute strategy, so it is even multiples of 2 minutes. The bad trades are in-between bars and some odd number of minutes and seconds. This suggests they are limit orders that were allowed in the middle of bars. They could even be from manual chart trading.
          3) If I go into the debugger and debug the strategy with a breakpoint in the OnExecution callback, the normal trades are the only ones that hit "OnExecution." This means that my strategy is not the source of the bad trades. All trades must go through the OnExecution callback. The bad trades do not show up.
          4) There is absolutely no way to explain how a strategy with "Entries per direction" of 1 can have a trade of 2S or 2L. This further proves that NT has some sort of database corruption or logical bug.

          I did a backup and restored the backup on another computer. The bad trades were also present after doing a restore. So this means the problem travels with the backup files.

          How can we make further progress on this problem? How does NT store the backtest results and how can there be different order ID sequences? I think that angle is the best one to get to the bottom of the bug. Is there any scenario where a user could cause a problem with the NT order ID?

          What is the difference between "Historical" and "Historical & RealTime" performance results? This is somewhat rhetorical so don't give me the quick url response. I understand the "Historical & RealTime" to add current trades that happened today. One problem may be related to the most recent transactions. It still is a bug, but would help isolate it.


          Originally posted by NinjaTrader_Bertrand View Post
          Thanks for the clarifications tradetree - you would then need to slowly iron out any variables that could effect this outcome to see where the issue is found - for example you mention IB - if you disconnect and for example connect to another connection (perhaps even External Feed) and then reload the NinjaScripts applied on both charts: do the discrepancies stay? Do both strategies use the same BarsRequired amount and chart series setup and also importantly fill algorithm? If you have a spare PC it would of course be interesting to know if you could reproduce at will then also there with your custom script...
          Last edited by tradetree; 04-11-2011, 08:43 PM.

          Comment


            #6
            Hi tradetree, thanks for the clarifications - for me to further look into I would need to have a reproducible scenario here on my end - would you please contact me via Help > Mail to Support and across your database, logs / traces and custom strategy used in your setup? I would then look into and attempt to reproduce here to further check into.

            If you review the historical strategy performance only you should only see the NT-... labellaed backtest orders, historical and realtime could include 'real' orders as well depending on how you're strategy is set to act when being enabled for realtime trading - with 'immediately submit' you would see working orders for the historical held position then included.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I have a more serious issue to work right now on another thread with Ryan. I may just watch this for awhile and see how it works going forward. I think if I only use "Historical" trade performance I will not get these strange trades showing up. I still think that trades that are not generated by the strategy I run the performance info on should not show up in "Realtime and Historical" performance. There were many trades that were outside of the strategy, but I don't expect to see them included in strategy performance statistics.

              Comment


                #8
                tradetree, thanks for replying here and your understanding is correct - the strategy performance report should only include trades belonging to the particular strategy - if this this reproducibly please let me know so.

                Thanks,
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RookieTrader, Today, 09:37 AM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by kulwinder73, Today, 10:31 AM
                0 responses
                5 views
                0 likes
                Last Post kulwinder73  
                Started by terofs, Yesterday, 04:18 PM
                1 response
                23 views
                0 likes
                Last Post terofs
                by terofs
                 
                Started by CommonWhale, Today, 09:55 AM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by Gerik, Today, 09:40 AM
                2 responses
                7 views
                0 likes
                Last Post Gerik
                by Gerik
                 
                Working...
                X