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

System.IndexOutOfRangeException get_TickSize()

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

    System.IndexOutOfRangeException get_TickSize()

    Hi, I have written the following method:

    Code:
    private double GetTickSizeValue()
    {
      double ticksizevalue = 0.0;
    
      try
      {
        ticksizevalue = Instrument.MasterInstrument.PointValue * (1 * TickSize);
      }
      catch (Exception ex)
      {
         string errorMsg = string.Format("GetTickSizeValue() {0}", ex.ToString());
         Debug.Print(errorMsg);
         Print(errorMsg);
         Log(errorMsg, LogLevel.Error);
       }
       return ticksizevalue;
    }
    i now get this error message at irregular intervals:

    GetTickSizeValue() System.IndexOutOfRangeException: The index was out of the array range.
    at NinjaTrader.NinjaScript.NinjaScriptBase.get_TickSi ze()
    at NinjaTrader.NinjaScript.Strategies.SidiUnmanaged.G etTickSizeValue()

    can someone maybe give me a tipp what to look for?
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thanks for your post.

    Can you provide further detail so I can replicate the error?

    Where/when are you calling the method from?

    What instruments have you tested this on?

    What data feed do you connect to?

    What specific version of NinjaTrader8 are you using? (look under help>about)

    Is there a particular sequence of steps to create a repeatable error?


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi _PaulH

      Version: 8.0.23.2 64-bit, tested and found on NQ 12-20 replay mode until now, Datafeed: CQG

      The error occurs without a specific initial situation, just sometime when my strategy is up and running, the method is called from different locations in my script.
      this will probably be a basic programming error on my part, but i don't know where to start the search;-)
      I am still testing in live sim mode now, I will also be happy to report here as soon as the error also occurs here.
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        Hello sidlercom80,

        Thanks for your reply.

        I would suggest adding a print before each call to the method.

        If and when the error occurs the last print should point to the last section that called and from there you can debug further.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello _PaulH, I also noticed the following error during testing:

          Code:
          DisplayItemsChartWindowBottom() System.IndexOutOfRangeException: Der Index war außerhalb des Arraybereichs.
          bei NinjaTrader.NinjaScript.DrawingTools.DrawingTool.S etDrawingToolCommonValues(IDrawingTool tool, String tag, Boolean isAutoScale, NinjaScriptBase ownerNinjaScript, Boolean isGlobal)
          bei NinjaTrader.NinjaScript.DrawingTools.Draw.TextFixe dCore(NinjaScriptBase owner, String tag, String text, TextPosition textPosition, Brush textBrush, SimpleFont font, Brush outlineBrush, Brush areaBrush, [B][COLOR=#e74c3c]Nullable`1 areaOpacity[/COLOR][/B], Boolean isGlobal, String templateName, DashStyleHelper outlineDashStyle, Int32 outlineWidth)
          bei NinjaTrader.NinjaScript.Strategies.SidiUnmanaged.DisplayItemsChartWindowBottom()
          Code:
          [Range(0, 100)]
          [Display(ResourceType = typeof(Custom.Resource), Name = "Area Opacity %", Description = "Select opacity to display on chart", Order = 4, GroupName = "ChartWindow Text PnL")]
          public int PnlAreaOpacity { get; set; }
          this is only an integer value, what is wrong here?
          Attached Files
          sidlercom80
          NinjaTrader Ecosystem Vendor - Sidi Trading

          Comment


            #6
            Hello sidlercom80,

            Thanks for your reply.

            Regarding this forum topic of System.IndexOutOfRangeException get_TickSize(), I would suggest calling it once in State.DataLoaded and assign the value to a class-level variable to then use that throughout.

            Your latest post was a bit confusing as it is not related to the topic. Going forward I would suggest a new topic when the subject has changed. This helps us keep the forum organized for searching.

            As a test, I would suggest replacing the opacity variable with an actual integer value and test again. Assuming the error continues we would suggest whatever you are doing with DisplayItemsChartWindowBottom should be done using TriggerCustomEvent(): reference: https://ninjatrader.com/support/help...ustomevent.htm
            Last edited by NinjaTrader_PaulH; 01-18-2021, 10:46 AM. Reason: Removed misplaced duplicate link
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hi NinjaTrader_PaulH , Thanks for the tip with TriggerCustomEvent(), that helped me ;-)
              sidlercom80
              NinjaTrader Ecosystem Vendor - Sidi Trading

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by frankthearm, Today, 09:08 AM
              7 responses
              29 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by NRITV, Today, 01:15 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by maybeimnotrader, Yesterday, 05:46 PM
              5 responses
              25 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by quantismo, Yesterday, 05:13 PM
              2 responses
              17 views
              0 likes
              Last Post quantismo  
              Started by adeelshahzad, Today, 03:54 AM
              5 responses
              33 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X