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

OnMarketDepth Problems

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

    OnMarketDepth Problems

    hi...
    i'm try to do an indicator using OnMarketDepth function..
    but i've problem with executions this function in a indicator....
    It give me following error :

    Error on calling 'OnMarketDepth' method for indicator 'MyCustomIndicator': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

    Now .. I do not know the specifics of this function because it is 'given by the system ninjatrader

    Someone can help me?

    #2
    Hello turbofib,

    Thank you for your post.

    The error message indicates that you may be trying to access a data series with an index that does not exist.

    May I see the code you have written in this method?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      The error is given to me after a successful execution after "n" candles..
      So dataserie exist as it would give me error already beginning..
      The indicator that I'm doing for now is empty .. I just called the function to see if it gave me problems


      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      /// <summary>
      /// Enter the description of your new custom indicator here
      /// </summary>
      [Description("Enter the description of your new custom indicator here")]
      public class MyCustomIndicator : Indicator
      {
      #region Variables
      // Wizard generated variables
      private long askCumulativeVolume;
      private long bidCumulativeVolume;
      private int depthLevels = 5;
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      #endregion

      /// <summary>
      /// This method is used to configure the indicator and is called once before any bar data is loaded.
      /// </summary>
      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      Overlay = false;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      //Plot0.Set(Close[0]);
      Plot0.Set(this.bidCumulativeVolume+this.askCumulat iveVolume);
      }
      protected override void OnMarketDepth(MarketDepthEventArgs e)
      {
      this.bidCumulativeVolume = e.MarketDepth.Bid.TotalVolume(this.DepthLevels);
      this.askCumulativeVolume = e.MarketDepth.Ask.TotalVolume(this.DepthLevels);
      }


      #region Properties
      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Plot0
      {
      get { return Values[0]; }
      }

      [Description("")]
      [GridCategory("Parameters")]
      public int MyInput0
      {
      get { return myInput0; }
      set { myInput0 = Math.Max(1, value); }
      }
      [Description("DepthLevels - number of level II levels to accumulate (min 1, max 5)"), NinjaTrader.Gui.Design.DisplayName("p1_DepthLevels "), GridCategory("Parameters")]
      public int DepthLevels
      {
      get
      {
      return this.depthLevels;
      }
      set
      {
      this.depthLevels = Math.Min(Math.Max(1, value), 5);
      }
      }
      #endregion
      }
      }

      Comment


        #4
        Hello turbofib,

        I have added the code you have supplied to an indicator.

        However, I am not getting the error message that you have received.

        Also, I don't think these lines of code can cause that error message.
        Code:
        this.bidCumulativeVolume = e.MarketDepth.Bid.TotalVolume(this.DepthLevels);
        this.askCumulativeVolume = e.MarketDepth.Ask.TotalVolume(this.DepthLevels);
        Have you removed code from this method?

        Attached is the indicator that I have put your code in.
        Follow these steps to import the NinjaScript:
        1. Download the script to your desktop, keep it in the compressed .zip file.
        2. From the Control Center window select the menu File > Utilities > Import NinjaScript
        3. Select the downloaded .zip file
        4. NinjaTrader will then confirm if the import has been successful.


        Critical *Note that on any files that say "File already exists on your PC" that start with an "@" symbol are the ones that came preloaded inside of NinjaTrader so you would say "No" so that you do not override those files.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The error is not immediate..
          It give me error after a certain time ...
          Now it works properly .. but if you wait a bit of time it give 'error (you should put it on a little volatile futures)



          In your file "turbotest.zip"...i test it and i say you if give me an error?

          Ok...i import it and now i try it and i give you if give me an error
          Last edited by turbofib; 01-14-2014, 01:49 PM.

          Comment


            #6
            Ok...i try your file and it give me following error :

            Error on calling 'OnMarketDepth' method for indicator 'TurbofibTest': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

            Comment


              #7
              Hi turbofib,

              What instrument and interval are you using to test this?

              I have added this to an ES 03-14 1 minute and 10 second chart and have let these run for about an hour and have not received the error message yet..
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                I tested it on 6E (euro dollar) graphic 30 seconds ... (I can not test it on other fut so I do not have the qualification for level2)


                Below i put setting of 6E
                Attached Files
                Last edited by turbofib; 01-14-2014, 03:14 PM.

                Comment


                  #9
                  Hello turbofib,

                  I have added the TurbofibTest indicator to a 6E 03-14 chart. The market isn't moving much so I have downloaded a day of Market Replay 6E data and allowed the chart to play back all of Jan 13th without receiving the error.

                  May I confirm that you have not modified the indicator that I have sent you in anyway?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    of course i don't have modify your indicator...but i think you must run it in realtime..not in replay

                    But if you do not know how to solve it .. I can make it run in the next few days by another person who has my same data feed (iqfeed)
                    Last edited by turbofib; 01-14-2014, 03:46 PM.

                    Comment


                      #11
                      Hi turbofib,

                      Please send me an email to support[at]ninjatrader[dot]com.

                      In the email please write Attn Chelsea and add a link to this forum thread.

                      I would like to schedule a call with you so that I may observe this on your machine.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        I have to be away for several days .... After sending all
                        thanks

                        Comment


                          #13
                          I noticed that it does to me that error .. but only in fut with many decimal places

                          Comment


                            #14
                            Hi esignal,

                            Are you getting this error with the sample indicator that I have provided in post #4?
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hi esignal,

                              Are you getting this error with the sample indicator that I have provided in post #4?
                              Yes..i try it....it give me error but sometimes not Always
                              and as turbofib me error only in futures with many decimal places

                              In other futures with 2 decimal places gives me no errors

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,605 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              8 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
                              4 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X