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

Calling another indicator, constructor issue

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

    Calling another indicator, constructor issue

    Hi,

    my script calls another indicator but I always get the error that there was no constructor that takes this number of arguments. Many properties of the called indicator don't have the NinjaCcriptPropertyAttribute, I fear this might be the problem. I attached a screenshot.
    Any suggestion?

    Greetings
    Seykool
    Attached Files

    #2
    Hello seykool,

    Yes that is the problem, if you want those to be a parameter of the constructor they need to be marked with NinjaScriptProperty.

    You also dont need the new keyword, indicators are called without new:

    EMA myEma = EMA(12);


    https://ninjatrader.com/support/help...criptAttribute
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Cheese,

      thanks for your reply and advice. I am calling the indicator in DataLoaded, therefore the new keyword.
      With regard to the constructor, that is a misunderstanding. It does what it is supposed to do. The problem is I can't call the indicator. I get the error that 'there wasn't a constructor with that number of arguments'. But as you can see on the screenshot, I am calling the exact same number of arguments that there are. This is the problem.

      Greetings

      Comment


        #4
        Hello seykool,

        You never use the new keyword on indicators, that is not required due to how indicators work. Calling new will not allow the indicator to work correctly. If you want to see how to call indicators correctly and set them up from OnStateChange you can use the strategy builder. To generate the code for your specific indicator you can use it in a condition and then click View Code.



        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,
          back to basics. That easy. Now it works. Thank you for the support!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by KonAdams, 05-07-2024, 10:53 PM
          9 responses
          25 views
          0 likes
          Last Post KonAdams  
          Started by haas88, 03-21-2024, 02:22 AM
          16 responses
          193 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by JimB17, 01-10-2020, 10:27 AM
          75 responses
          2,792 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by JGriff5646, 05-07-2024, 10:02 PM
          3 responses
          29 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by dp8282, Today, 07:35 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X