• 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

Creating a Reusable Class

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

    Creating a Reusable Class

    I created an abstract CustomIndicatorBase class, in order to reuse my Code... I did it in NT 7 for my startegies and it worked well. But when I try to create them for NT 8 as an Indicator, the ninjatrader Generated Code returns a problem. When it tries to create a new Instance of the Indicator( since Abstract Classes cannot be instantiated) I get a cannot create an instance error:

    . How can I tell NT not try to create an instance of this indicator class and still be able to use it and create future indicators?

    #2
    Hello Yandychang,

    Thank you for your post.

    Can you provide an example of the code that generates an error?
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Abstract Class

      Sure, Attached is a test code that reproduces the error, could not make it into a Zip because NT 8 says I have to fix the error before exporting...
      Attached Files

      Comment


        #4
        Hello,

        Thank you for providing the sample,

        I tried this concept in NT7 but do also see the same error that the abstract class can not be created. Additionally I see that you said in NT7 you used this for Strategies and now are using it for Indicators, this would likely be expected as there is no Wrapper code appended to a strategy.

        Could you compose a very simple example of the structure used in NT7 so we can confirm that this is identical to what you had done that was already working?


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

        Comment


          #5
          Regarding Abstract Class

          Actually, On NT 7, it did not throw any errors, it compiled Fine... NT skipped adding the Ninjascript Generated Code... my NT7 version is 7.0.1000.30.
          Attached Files

          Comment


            #6
            Hello,

            Thank you for the sample.

            I do see that when you remove the generated code it allows it to compile in nt7. I am unsure in regard to design if this was expected or not, but in either case I have submitted this sample to development for further review to see if this can be moved to match nt7.

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

            Comment


              #7
              I have not tried this yet, but I noticed that the file name generated by nt7 starts with @@... Maybe renaming the file and adding @@ in front of the name in NT8 makes a quick fix...

              Comment


                #8
                Hello,

                Where are you seeing a file name generated by nt7 that starts with @@?

                @@ in NT8 would be to exclude a NinjaScript item, this is what occurs when you right click and exclude from compilation in the new editor.

                For NinjaTrader 7 I would be unsure where you are seeing @@.

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

                Comment


                  #9
                  Never mind then, it was a file I had excluded to be able to compile... I think it was NT 8

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pecunianonolet, 11-28-2016, 03:34 AM
                  3 responses
                  3,134 views
                  0 likes
                  Last Post DaveS
                  by DaveS
                   
                  Started by contrax, Today, 08:20 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post contrax
                  by contrax
                   
                  Started by brownsfan019, Today, 07:54 AM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Started by Amitabha, Today, 04:50 AM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_Marco  
                  Started by JulieG, Today, 12:40 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChrisSch  
                  Working...
                  X