Announcement

Collapse
No announcement yet.

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.

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      649 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      370 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      576 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X