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

Error compiling user indicator

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

    Error compiling user indicator

    Hi,
    I wrote an indicator called SRMomentum which I am trying to call from another indicator called SRMomentumSetup.
    SRMomentum is working fine as expected and has the following constuctor

    public SRMomentum SRMomentum(int period)
    {
    return SRMomentum(Input, period);
    }


    In SRMomentumSetup, I declare my class variables:

    SRMomentum lowMomentum, highMomentum;

    and instantiate the objects in State.DataLoaded:
    lowMomentum = new SRMomentum(LowPeriod);
    highMomentum = new SRMomentum(HighPeriod);


    However I am getting the error for both these lines:

    'Ninjatrader.NinjaScript.Indicators.SRMomentum' does not contain a constructor that takes 1 arguments

    Any ideas what the problem could be please?
    Regards,
    iq

    #2
    Hi iq, thanks for your note.

    The "new" keyword should not be used to instantiate a NinjaScript object. NinjaTrader calls "new" internally and this is where the NinjaTrader generated code at the bottom of all indicators comes into play. Incidentally, no custom constructor is needed. If you remove "new" from the two lines and look at the parameter list that SRMomentum can take then the code will compile correctly. It likely needs an input series, such as Close for example.

    e.g. lowMomentum = SRMomentum(Close, LowPeriod);

    Take a look at the parameter list when you type "SRMomentum(", the editor will tell you all the parameters needed.

    Best regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris - Doh! I completely firgot - thanks!
      Regards,
      iq

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by guillembm, Yesterday, 11:25 AM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by junkone, 04-21-2024, 07:17 AM
      10 responses
      148 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by tsantospinto, 04-12-2024, 07:04 PM
      6 responses
      101 views
      0 likes
      Last Post tsantospinto  
      Started by rocketman7, Today, 02:12 AM
      5 responses
      26 views
      0 likes
      Last Post rocketman7  
      Started by ZenCortexReal, Today, 08:54 AM
      0 responses
      1 view
      0 likes
      Last Post ZenCortexReal  
      Working...
      X