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 'OnRender' method

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

    Error on calling 'OnRender' method

    Hello,

    I will preface this question with the statement that I have no idea what I'm doing!

    I'm attempting to expand the stock Volume Zones indicator to display volume for each tick.

    I've, essentially, copied the stock Volume Zones indicator into a new script and changed the name. I've changed two variables as such:

    int volumeBarCount = BarCount;
    to
    int volumeBarCount = Convert.ToInt32(priceRange/TickSize);

    and

    double priceBoxSize = priceRange / volumeBarCount;
    to
    double priceBoxSize = TickSize;

    I repositioned the volumebarcount line to under the pricerange. The script compiles. I get nothing on the chart. Shock, horror.

    I added a print command in the //Pass 2 rectangle rendering loop, one line:

    Print("Price: " + priceLower + " Volume: " + volumeMax);

    to see if it works.

    In the output window, I get this message and nothing else:

    Indicator 'Volume Zones Tick': Error on calling 'OnRender' method on bar 3128: Index was outside the bounds of the array.

    I have no idea what this means. Am I trying to plot too much data on the screen? What can I do to make it work?

    Cheers,
    Dan.
    Last edited by NinjaTrader_PatrickH; 03-21-2017, 08:52 AM.

    #2
    Hello dumdumdan,

    Thanks for writing in.

    Without the full unprotected source code I’m unable to look into this further on my end. (We have also removed the listed file as DLL's are not allow in our File Sharing Guidelines.) In addition, debugging customer code is out of the scope of NinjaScript support. However, if you’d like I could have someone from our business development team pass over a list of third party developers that you could contact about debugging your code. If this is the case please write in to platformsupport[at]ninjatrader[dot]com with the text "1678176 ATTN Jim" in the subject of the email.

    The error you are getting is reported to be from OnRender() and is specifically about an array being referenced with an invalid index. I suggest to add if statements to check if what you are referencing exists before you reference it and try to use that data.

    I would also suggest to store any data you would like to access in OnRender() to their own variables as OnBarUpdate() and OnRender() are not called in sync with each other, and calling Close[CurrentBar] may not give an accurate index.

    You may also debug this further by commenting out any lines that might be throwing the indexing error in OnRender(), and adding Print() statements to see if the code reaches where the error would have occurred.

    Further debugging tips can be found on our forum here: http://ninjatrader.com/support/forum...ead.php?t=3418

    Please let me know if I may be of further help.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by dumdumdan View Post
      I'm attempting to expand the stock Volume Zones indicator to display volume for each tick.
      Dan,
      You might want to take a look at the built-in VolumeProfile indicator instead of VolumeZones. It might do what you want without modification.

      Comment


        #4
        Thanks Jim, these are great tips. I will try looking into the location of my variables in the code. This sounds like my problem.

        Tradesmart, I am always on/off my PC and I find it annoying to wait for the indicator to build itself. Any thoughts? You use it?

        Comment


          #5
          Originally posted by dumdumdan View Post
          I am always on/off my PC and I find it annoying to wait for the indicator to build itself. Any thoughts? You use it?
          The time to load depends upon how many days or bars your chart contains. When using a TickReplay-enabled indicator, such as VolumeProfile, I always load the absolute minimum, typically 0 days unless I'm interested in looking at a longer timeframe and then I use my own customization of VolumeProfile. If you want tick-level granularity on historical bars, there's really no way around using a TickReplay indicator that gets its data from OnMarketData().

          Comment


            #6
            If you want tick-level granularity on historical bars, there's really no way around using a TickReplay indicator that gets its data from OnMarketData().
            Roger.

            Cheers,
            Dan.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bmartz, 03-12-2024, 06:12 AM
            5 responses
            32 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by Aviram Y, Today, 05:29 AM
            4 responses
            13 views
            0 likes
            Last Post Aviram Y  
            Started by algospoke, 04-17-2024, 06:40 PM
            3 responses
            28 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by gentlebenthebear, Today, 01:30 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by cls71, Today, 04:45 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X