Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

[BUG] AllTrades in Markert Replay

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

    #16
    Hey, of course, they are not the same script, I know this, I copied in the OnPositionUpdate() function from your script into my script ..,

    The offending line is the following from your OnPositionUpdate() function ..

    Code:
     Print(string.Format("{0}", SystemPerformance.AllTrades[i].ToString()));
    from the loop

    Code:
    if (SystemPerformance.AllTrades.TradesCount > 0)                 {
                        Print(string.Format("{0} AllTrades.TradesCount: {1}", Time[0], SystemPerformance.AllTrades.TradesCount.ToString()));
    
                        for (int i = 0; i < SystemPerformance.AllTrades.TradesCount; i++)
                        {
                            //Print(string.Format("{0}", SystemPerformance.AllTrades[i].ToString()));
                        }
                    }

    I can't print the values of that line because of the error below.

    --
    Strategy '<name>197047982': Error on calling 'OnPositionUpdate' method on bar 15310: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    --

    If I comment out that offending line, or remove your OnPositionUpdate() function my strategy script works fine.

    All I wanted was to write some values from each of the trades as they happen/exit into a file, I found your code when looking how to access trade info, so I thought looping through the trade list and printing the data was the first step, but I have not made it past that bit yet :?

    I hope that clarifies the sequence of events .. I am in no way saying that our 2 x scripts are the same, they are not, but the OnPositionUpdate() is the same in both.

    There is something going on in my script that is stopping me looping through the list of trades and extracting the data, which, I have no idea where to go with that .. should just work right ? am assuming you have not seen this before and its not a bug/defect ?

    Is there some sort of low level debugger we can attach or run ?




    Comment


      #17
      Hello 12tkram,

      What is the value of i when the error occurs?

      What is the value of SystemPerformance.AllTrades.TradesCount?

      Below is a link to the help guide on VisualStudio debugging. This would start falling outside of what I may assist with and why our support relies on prints.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Hey, thanks for looking..

        What is the value of i when the error occurs? 0
        SystemPerformance.AllTrades.TradesCount ? 1

        ref:
        --
        24/02/2020 11:54:00 AllTrades.TradesCount: 1
        24/02/2020 11:54:00 >>> loop i == 0
        Strategy '<name>/197048000': Error on calling 'OnPositionUpdate' method on bar 7674: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
        --

        Comment


          #19
          Hello 12tkram,

          The index appears valid. My suspicion is you are looking at the wrong index.

          A suggestion would be, you could use the script I have provided you as a starting strategy and then add your code to it since we know this is working.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            K, yeh, add sections at a time, sounds like a plan.

            Comment


              #21
              done and it works, the only thing I found to cause a bars error was as erroneous "IncludeTradeHistoryInBacktest = false;" in (State == State.Configure) .. however, commenting that out of the original did not fix the issue .. not even sure what fixed it, all sections pasted in fine, tested after each paste until the complete code was copied over .. thanks for your help again .. expect there is some weird character somewhere in the orig ..

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              30 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              124 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              64 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              41 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X