• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Calling Indicator Error

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

    Indicator Calling Indicator Error

    Hi,

    I am calling a custom indicator (indicator B) from within another custom indicator's (indicator A's) OnBarUpdate().I am getting an 'Object reference not set to an instance of an object.' error when I reference the called indicator (B). So there seems to be a null exception happening here. Is there a way to fix this? Any suggestions would be appreciated. Thank you.

    #2
    Hello,

    Thank you for the post.

    I wanted to see if you could post an example of the syntax where you are calling the indicator so I could get a better idea of what may be null.

    If you are creating an instance of the indicator, perhaps it is the syntax used, I would not be certain from the details so far.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      The calling syntax is:

      Code:
      Print("=========== PB_RTS_RA().ExposedResults.BarValue = "+PB_RTS_RA(BarsArray[1], "Version 1", false, 12).ExposedResults.BarValue);

      Comment


        #4
        Hello,

        Thank you for the reply.

        Have you at this point checked which part of this is null?

        I see there are two sub objects which are used which could potentially be null :

        Code:
        PB_RTS_RA(BarsArray[1], "Version 1", false, 12).ExposedResults.BarValue
        Could you check that calling only the indicator does not create the error?

        Code:
        PB_RTS_RA(BarsArray[1], "Version 1", false, 12)[0]
        This would entail you have 1 plot, otherwise, you would need to check that the object being used is not null:

        Code:
        if(PB_RTS_RA(BarsArray[1], "Version 1", false, 12).ExposedResults != null)
        Can you try these items and report the results?

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,

          So I have tried your suggestions and here are the results.

          1. As this is not a plot, I did
          Code:
          PB_RTS_RA(BarsArray[1], "Version", false, 12);
          This works and does NOT create the error message.

          2. Next I tried
          Code:
          if (PB_RTS_RA(BarsArray[1], "Version", false, 12).ExposedResults != null)
              Print(">>>>>>>>> NOT NULL <<<<<<<<<<<<<<<");
          This prints 'NOT NULL' but creates the error message.

          3. Finally I tried
          Code:
          if (PB_RTS_RA(BarsArray[1], "Version", false, 12).ExposedResults.BarValue != null)
              Print(">>>>>>>>> NOT NULL BarValue <<<<<<<<<<<<<<<");
          This prints NOT NULL BarValue but also creates the error message.

          Comment


            #6
            Hello,

            Thank you for the reply.

            I believe I would likely need to see the script in more detail to tell what is happening here. The test seems to be inconclusive as to what is null.

            I would suggest starting by checking the indicator to ensure that the items you are using are being created as they should be when called by using prints. Checking the prints when applied to a chart versus being called from the script would help to know if something is happening different or incorrect.

            You could also create a more simple using a simple type like an int to ensure you can pass the int property as expected. This would highlight other problems that may be related to the syntax used.

            If you have a small example of an indicator being called from another script like you are currently using that you can upload, I could take a look at that as well.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,

              I think the issue is that the object 'ExposedResults' is not being instantiated in the calling indicator. Can you please show me how I might be able to instantiate the object 'ExposedResults' (which is part of another indicator) in the calling indicator? Your help would be greatly appreciated. Thank you.

              Comment


                #8
                Hello,

                Thank you for the reply.

                If the object is not being instantiated you may need to look into the indicator to see why that's happening, or why the logic to do this is not happening. Where do you currently have this property being initialized?

                From outside the indicator, you would need to create a new instance of that object for the type it is. for example :

                Code:
                PB_RTS_RA(BarsArray[1], "Version", false, 12).ExposedResults = new ExposedResultsObjectType();
                Although this may not be the correct solution in the case it should be initialized somewhere else already and that is not happening.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse,

                  When I do the initialization as you suggest, I get the error that
                  RA(BarsArray[1], "Version", false, 12) does not have a constructor that takes 4 arguments.

                  However, Intellisense shows that it does take 3 or 4 arguments depending on whether an input series is used. I am assuming the indicator constructors are public, right?

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    In this case, I couldn't really answer this question as I cannot see the source code generated.

                    The Indicators constructor is based on the public properties in the script that are exposed for NinjaScript. There is also an input constructor created.

                    For this item, I would suggest to either create a sample indicator that only contains the public properties being used so we can see what is being generated, or to reduce the script to find the problem.

                    The error is noting that there are not enough overloads for the parameters you provided, this can be the case if you have compiled and the NinjaScript generated code did not include one of your properties.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Hi Jesse,

                      I am still having issues with this. I have solved the error issues but no data is being passed between the indicators.I have built a small sample code. Would you be able to have a look at it to see what's going on?

                      Comment


                        #12
                        Hello,

                        Yes, please feel free to upload a simple sample of the problem. If you have extracted the properties in question and formed a sample that would be best to review the situation with.

                        You can always upload samples to the forum, or if you have something you do not want to share you can use the platform support [at] ninjatrader.com email. I do want to note, if your code cannot be shared publically and is very large, you may instead want to reduce it to a simple sample for best results.


                        I look forward to being of further assistance.
                        JesseNinjaTrader Customer Service

                        Comment


                          #13
                          Hi Jesse,

                          The code is relatively simple. I will email it to your attention.
                          It should work, but as it doesn't, I guess I am missing something. Thank you for having a look at it. Your input would be greatly appreciated.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Maxwell123, Today, 12:34 AM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_ChrisSch  
                          Started by memonic, Today, 02:21 AM
                          0 responses
                          2 views
                          0 likes
                          Last Post memonic
                          by memonic
                           
                          Started by Guru73, Yesterday, 02:47 AM
                          5 responses
                          33 views
                          0 likes
                          Last Post Guru73
                          by Guru73
                           
                          Started by Guru73, Today, 01:35 AM
                          0 responses
                          2 views
                          0 likes
                          Last Post Guru73
                          by Guru73
                           
                          Started by i2w8am9ii2, Yesterday, 04:41 PM
                          1 response
                          11 views
                          0 likes
                          Last Post Lancer
                          by Lancer
                           
                          Working...
                          X