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

SystemPerformance.AllTrades.Count returns 0

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

    #16
    Hello waynewright33,

    Thank you for your patience.

    The Daily bars would not trigger ExitOnSessionClose as each Daily bar is a closed session. The trades count is 0 because no trade occurs when the conditions are true. The trade is not considered complete until the exit occurs.

    Please let me know if you have any questions.

    Comment


      #17
      Oh you're welcome. While waiting I was able to work around the bug last week by accessing the last bar of the instrument to issue a direct exit order to close the trade rather than letting it be handled by "Exit on session close".

      It seems you don't understand the problem. The daily bars Trigger ExitOnSession close just fine, right as the last bar of the instrument closes.

      The primary bars, in this case a continuous index, act as a running calendar. As we run through the secondary bars there would indeed be a case when a trade on an expired secondary series has completed, by Exitonsessionclose as the contracts expire.

      So, there is a bug, because there's no reason why a trade that is exited by "exit on session close" should not be counted as a trade. It has nothing to do with the daily bars, this method is being called on the expiry of the contract.

      Comment


        #18
        Hello waynewright33,

        Thank you for your patience.

        I put together a video to help explain this further. Please review the video at the following link: https://www.screencast.com/t/eq7R9qnaF5K5

        Please let me know if you have any questions.

        Comment


          #19
          Thanks for the video Patrick.


          Did you run the strategy?

          You will see that as time goes forward through the backtest, there are indeed trades that open, and close. The j counter is there so that the strategy only takes a trade on the first bar of the new instrument. The primary index just acts as "time". So as time goes along, if it's the first bar of a new contract, it enters a position, then j goes up so that the next time a new contract comes into play, because time has passed, it will again enter on the first bar of the contract.

          The problem is that while this is taking place, the trades that have exited via exit on session close don't seem to be recognized as trades by the system. I don't know how else to explain this to you.

          I've fixed the problem by intercepting the last bar of each contract as it expires and forcing the strategy to close the position before the contract actually expires. Thereby intervening in the position being exited by "Exit On Session Close". This results in the behavior I expect, with all my trades having trade performance values.

          If the problem was with my code as you suggest, than this would not have fixed the problem.


          ***** The only thing I can think of, is that once the last bar of the data series is reached, your software actually holds the position and lets it just ride until the entire strategy has finished running, and THEN processes all of the trades that were still open when the "sessions ended" or in this case, when there is no more data in the contract because it expired. I suspect this might be whats happening, and if so it seems like the wrong way to handle it.
          Last edited by waynewright33; 02-23-2017, 12:38 PM.

          Comment


            #20
            Hello waynewright33,

            Thank you for your response.

            In testing the strategy only creates one position per contract, it then exits each of these at the end of the data for that expiry. There is no means within your code for the Print to ever produce any value other than 0.

            To reiterate, on a 1 Day bar the ExitOnSessionClose does not occur on each day. Your code only runs once for each bar and is printing a value that is 0 because no trades have closed.

            Your logic will need to be corrected to handle the fact that Daily bars do not have ExitOnSessionClose on each day and to call the performance for trades only once a trade is truly closed.

            Please let me know if you have any questions.

            Comment


              #21
              Dude... you can word it however you want. Sure there's a problem with my code, because of the way NT is handling things. "Once the trade is truly closed"...? On the summary, there is a record of the trade closing with a TIME and DATE that is the last bar of the contract. If NT is going to report that, then it should call a method that makes it a "true trade". Like what don't you get? You clearly know what I'm trying to accomplish, and the problem is that NT isn't handling the EXIT trade till after the strategy is finished, even though it's posting the trade time and date as the last day of the contract.

              Hows this then, perhaps a suggestion. Once there is no longer any data in the data series, immediately call a method that exits any open trades and stores the damn trade values in something so they can be accessed, because they are completed trades.

              Thanks,

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              3 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Working...
              X