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

indicator.XXX is a method which is not valid

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

    indicator.XXX is a method which is not valid

    I have a MAJOR problem.

    I made a minor change to a partial class that allow communication between different indicators. - public partial class GV : Indicator - is in the indicator folder. Three other indicators refer to that partial class and communicate directly with the dot syntax. GV.method().

    It was working fine for months before I compile the minor change but now I have compile errors coming from the three indicators :

    'NinjaTrader.NinjaScript.Indicators.Indicator.GV() ' is a 'method', which is not valid in the given context CS0119

    #2
    Hello,

    Thank you for the post.

    Could you provide some context on what was being used before and what was changed? Without these details, it would be very difficult to say what is different to provide an answer.

    It may be easiest to undo the change you had made and revert to the prior state where it had compiled, and then provide the syntax you are trying to add or change in contrast to what already works. This would be the best case for me to provide more details.

    If that is not possible, you would likely need to find where you use the partial class in each script and comment the logic out. Ensure all scripts compile and from that point, you could test the syntax in a single script to see why it's not compiling or finding the method in question.

    The error is only telling me that you are trying to call a method in the wrong context, without seeing the syntax used and where this is used I wouldn't really be sure how to relate that to give you direction on what to change.

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

    Comment


      #3
      Hi Jesse

      This is what I did. I had backups and got the indicator back before I did any changes.

      This is why it is so confusing.

      Comment


        #4
        Hello,

        So you have already restored a backup to the state where it should compile is this correct? If so, did you also restore the prior versions of the indicators that use this partial class? If you had changed anything in the indicator or how you call the class/methods, that would need to be reverted as well.

        An alternative would be to exclude the partial class/indicators so you can compile and create a new partial class that is empty. Create a single method and ensure you can call that dummy method from the indicator. You could then check what is different between the real partial class and the dummy you just made as a test.

        If you can provide any sample of how you call the class along with the class and method, I could provide further assistance. Without the syntax, it would just be a guessing game on what changed and what you could try in order to resolve the error.

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

        Comment


          #5
          Jesse

          Is it possible to have remote help on this ?

          Comment


            #6
            Hello,

            We generally don't provide remote assistance for NinjaScript inquiries specifically as our support does not provide debugging services. I would be able to offer assistance if you can provide a sample of the code in question but it would need to be a sample of what is not working specifically and not an entire script that needs to be debugged.

            If you have something you don't want to share publically, you could use our platform support [at] ninjatrader.com address to provide files and we could work together through email.

            I always suggest rather than sending in the actual script in question to extract only the logic in error and test from a new script that has no relevance to your proprietary code. This could be uploaded publically to explain your question and we could both make modifications to the sample as needed to reach a working result.


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

            Comment


              #7
              That would be complicated to do because I have 4 indicators linked together and I have code all over the place.

              The problem is really based on namespace I think.

              If I go to my indicators that are dependent on the partial class I see that it shows the partial class as an indicator and not a partial class. I have access to properties related to indicators.

              If from these indicators I refer the partial class to its full name like : NinjaTrader.NinjaScript.Indicators.GV it seems to take the partial class as such.

              Comment


                #8
                Hello,

                Is the namespace what you have changed or have you potentially defined an indicator with the same name as the partial class?

                I wouldn't really be able to say without some kind of example of what is changed and how the code is being used. Really all I could suggest would be to remove the items in their entirety to start from a compiled state and try to work out what you had changed in the partial class and other scripts that use it. If the code is all over the place and complex, a simple test may be needed to find the reason the complex item is not working.

                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Jesse

                  OK I have changed all references to GV to its full name NinjaTrader.NinjaScript.Indicators.GV solved all problems. Everything now compile.

                  These indicators are being exported to customers will that change cause problems ?

                  Comment


                    #10
                    Hello,

                    You would need to test if the item can be imported in a clean installation of the platform, not the one you are currently developing in. This would be something you would need to test after making the change, as I cannot see what code you are using I could not say it will or will not work. The best I could give would be a guess which is not something I would like to give when talking about syntax.

                    If you are unsure how to make a clean testing installation, I could provide steps on how to do that in another post. Otherwise, you would just need to make a clean install, and try importing the item before you send it to clients. In reality, this step is suggested for every export you do and every new version you release as a quality control step. There are cases where exporting from your development environment may render the item nonimportable by end users so it is always suggested to export from a completely clean stock installation.



                    Please let me know if I may be of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Jesse

                      Yes I would be interested in knowing about the steps to make a clean testing installation.

                      Thank you !

                      Comment


                        #12
                        Hello,

                        To create a clean installation to export your NinjaScript objects from please follow the instructions below:
                        • Export the code you want as the final export as source code
                        • Exit the platform
                        • Go to (My) Documents > rename the 'NinjaTrader 8' folder to 'NinjaTrader 8.Prev'.
                        • Then re-install from the following link: http://ninjatrader.com/GetStarted
                        • When you reinstall it will recreate the user folder you had just renamed with only stock files.
                        • Now you can start the platform and import the source code for the item you want to export as a compiled assembly. Because there are no other items in this installation, only the item you want to export would be included.
                        • To switch between the two installs; shut down NinjaTrader > rename the new installation to 'NinjaTrader 8.Dev' under (My) Documents > then rename the 'NinjaTrader 8.Prev' to 'NinjaTrader 8'. NinjaTrader looks for the user folder named NinjaTrader 8 specifically.


                        You would only need to do this process to get the two folders, once you have two separate user folders you can simply exit and rename the folders to change installations.

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

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by MarianApalaghiei, Today, 10:49 PM
                        3 responses
                        9 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by XXtrader, Today, 11:30 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post XXtrader  
                        Started by love2code2trade, Yesterday, 01:45 PM
                        4 responses
                        28 views
                        0 likes
                        Last Post love2code2trade  
                        Started by funk10101, Today, 09:43 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post funk10101  
                        Started by pkefal, 04-11-2024, 07:39 AM
                        11 responses
                        37 views
                        0 likes
                        Last Post jeronymite  
                        Working...
                        X