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

Error on calling On render method

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

    Error on calling On render method

    Hello

    I have written an indicator with several series that uses OnRender method for drawing. It works perfectly in a chart with just one data serie applied, but when there are two series on chart, error "you are accesing an index...." appears...

    What should I consider to fix this error?

    Thanks in advance

    #2
    Hi Impeesa, thanks for posting.

    This implies that you are accessing an index on the secondary series that is not loaded yet. Make sure to check for at least X bars in each series using CurrentBars[] array where X is the largest lookback period for each series.

    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello again, Chris

      Thanks for your reply. Maybe I have not explain well. Indicator runs perfectly in any chart with only one chart serie and there is not issues with series hosted in it.

      Error only appears when chart has two data series loaded even if they are not plot in same panel. Any suggestion?

      Sincerely,

      Comment


        #4
        Hi Impeesa, thanks for your reply.

        I can not tell what the issue is from the description. Please use Visual Studio to break at the line where the exception is occurring:



        Also, test the SampleCustomRender indicator. Does the same thing happen on this indicator? If not your indicator will need to be reduced to identify the issue or use Visual Studio to identify the problem line in the code. The indicator will only see the data of the Input series that is selected in the indicator menu.

        Best regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hello, Chris

          I have followed your advise and Visual Studio does not show exception at all.

          Indicator works ok:

          1.- Charts with just one serie running.
          2.- Charts with two or more series running if session is opened, if there is at least one bar in chart.

          In both cases indicator is running on primary serie of chart.

          Indicator fails:

          1.- Charts with two or more series in the opening bar of session.

          Failed to call 'Add' method: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource) at NinjaTrader.Gui.Chart.MultiEquidistant.GetTimeBySl otIndex(Int32 slotIndex) at NinjaTrader.Gui.Chart.ChartBars.MultiEqSaveTimes(M ultiEquidistant equidistantMulti, DateTime fromTime) at NinjaTrader.Gui.Chart.MultiEquidistant.UpdateBar2S lotMappings(BarsSeries barsSeries, Int32 minBarIndex, Int32 maxBarIndex) at NinjaTrader.Gui.Chart.ChartControl.OnBarsUpdate(Ob ject sender, BarsUpdateEventArgs e) at NinjaTrader.Data.BarsSeries.Add(Bars bars, Double open, Double high, Double low, Double close, DateTime time, Int64 volume, Double tickSize, Boolean isBar, Double bid, Double ask)

          Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'HRESULT: [0x88990016], Module: [SharpDX.Direct2D1], ApiCode: [D2DERR_PUSH_POP_UNBALANCED/PushPopUnbalanced], Message: The push and pop calls were unbalanced. '


          Unhandled exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index



          As debugging does not identify the problem, could it be a bug in NT8? If you think it is not, how can I follow working to fix it?

          Sincerely,
          Last edited by Impeesa; 11-16-2021, 09:52 AM.

          Comment


            #6
            Hi Impeesa, thanks for your reply.

            I can take a look at a reduced copy of your script to see if I can identify a problem. Please Export and send me your reduced copy of the script to scriptingsupport at ninjatrader.com referencing "Attn ChrisL 3333348" and please let me know how to set up the chart to reproduce as well (the chart instrument, bar type, etc) include steps I should take to reproduce.

            Kind regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by dcriador, Today, 12:06 PM
            0 responses
            6 views
            0 likes
            Last Post dcriador  
            Started by dcriador, Today, 12:04 PM
            0 responses
            4 views
            0 likes
            Last Post dcriador  
            Started by cutzpr, Today, 08:54 AM
            0 responses
            11 views
            0 likes
            Last Post cutzpr
            by cutzpr
             
            Started by benmarkal, Today, 08:44 AM
            0 responses
            16 views
            0 likes
            Last Post benmarkal  
            Started by Tin34, Today, 03:30 AM
            2 responses
            28 views
            0 likes
            Last Post Tin34
            by Tin34
             
            Working...
            X