Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IDataSeries problem

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

    IDataSeries problem

    I've tried to code an indicator that gives some warning with various actions of the CCI. It doesn't compile and I'm pretty sure I need to somehow use IDataSeries, but that is very confusing to me. Can you take a look?

    Richard
    Attached Files

    #2
    I noticed another mistake in my prior post so I deleted it. Here is a new one.
    There are several issues I see.

    1) Your usage of CCI is incorrect.

    Should be CCI(Length) instead of CCI(Length, 0). This will use the Close price, if you wanted the High price use CCI(High, Length)

    2)

    You have:

    double x = CCI(Length, 0);

    should be:

    double x = CCI(Length)[0];

    You are assigning the indicator itself to x instead of the value of the indicator at a specific bar.
    RayNinjaTrader Customer Service

    Comment


      #3
      Error Message

      Thanks for helping.

      I've made that change but when I try to compile I get the message: "Your indicator has one or more recursive properties that could cause NinjaTrader to crash: Length. Do you want to edit these properties?"

      I can't see what would be wrong with Length, but don't know what recursive is.

      Comment


        #4
        I can't tell with the error message about recursive properties if these other errors are still there, but they say: "The best overloaded method match for 'NinjaTrader.Data.Indicator.Indicator.CCI(NinjaTra der.Data.IDataSeries,int)' has some invalid arguments. Argument '1': cannot convert of 'int' to 'NinjaTrader.Data.IDataSeries'

        Comment


          #5
          Recursive means that you have an infinite loop in your code.

          Check under properties, you will see something like:

          public int Length

          inside you will see Length = value;

          change to lower case

          length = value;

          also change the "getter" to show "return length" instead of "return Length"
          RayNinjaTrader Customer Service

          Comment


            #6
            Partial fix

            Your 4:12 post seems to have taken care of the recursive message. Still have issue of IDataSeries.

            I appreciate your help.

            Comment


              #7
              Eureka!

              Found problem in my use of x in CrossAbove, CrossBelow. Now OK -- at least compiles. Now I have to see if it works! Thanks.

              Comment


                #8
                Double check all methods (indicators/functions) that you use and ensure you are passing in the correct parameter types.

                The problem is that you are passing in int and double values into the CrossAbove() and CrossBelow() methods. Check the DOC on these methods to see the correct syntax. They can accept a double value but it also needs at least one value which is of type IDataSeries. You can check the DOC on the DataSeries Class as well to gain an understanding of how that works.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  I'll let you know when I am able to test this to see if it works.

                  I have studied the documentation on DataSeries but just don't understand it.

                  Comment


                    #10
                    Compiles but doesn't work

                    I have gotten the code attached to compile with no errors and it appears to have the right logic to me, but when I apply it to a chart nothing happens.

                    This code is to do the following:

                    Determine if the CCI one bar back is above an Upper bound.
                    If so, as the current bar approaches within a Warning amount, sound an alert and color the price bars.
                    As it then crosses the Upper bound, sound another alert and color the price bars another color.

                    Same for when CCI is below the Lower bound.

                    What am I missing please?
                    Attached Files

                    Comment


                      #11
                      Hi Richard,

                      Unfortunately we are unable to provide debugging support however, we do help out time permitting as you have already experienced.

                      Any time an indicator does not work, there usually will be an error in the log tab of the control center window which might provide you a clue as to what the issue might be.

                      A common error is an index out of range error which usually is a result of trying to access a bar that does not yet exist. I would check your code for that.

                      If you access something like Close[2] for the close of 2 bars ago, you want to make sure you have something like

                      if (CurrentBar < 2)
                      return;

                      Since this will check to make sure there are enough bars to get a value from 2 bars ago.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Thanks, that helped. Working on logic now.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by 7robert, Today, 10:08 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post 7robert
                        by 7robert
                         
                        Started by bosajin, Today, 09:15 AM
                        1 response
                        11 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Started by Noobie2B, Today, 09:14 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by Zombie, Yesterday, 06:23 PM
                        1 response
                        17 views
                        0 likes
                        Last Post NinjaTrader_Kate  
                        Started by EquityTrader, Today, 09:05 AM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X