Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to create instance-error log message

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

    Unable to create instance-error log message

    This problem is solved. Sorry for any inconvenience caused.

    With each complication of NinjaScript code, I receive the following error message in the NinjaTrader log:

    Unable to create instance of 'NinjaTrader.Strategy.FixedPercent2'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Constructor for type NinjaTrader.Strategy.FixedPercent2 is not found.
    The whole code section for these classes is:
    PHP Code:
    class MoneyManagement2 : Strategy
    {
        protected double accountSize;
    
        public MoneyManagement2(double accountSize)
        {
            this.accountSize = accountSize;
        }
    }
    
    class FixedPercent2 : MoneyManagement2
    {
        private float fixedPercentage;
    
        public FixedPercent2(double accountSize, float fixedPercentage)
            : base(accountSize)
        {
            this.fixedPercentage = fixedPercentage;
        }
    } 
    
    Some other points:
    • There are no errors in the NinjaScript editor after compiling,
    • There are no errors or warnings in Visual Studio,
    • As far as I know the above code example is correct,
    • Creating an instance of these classes works and they can be used without errors.
    • I'm running the latest stable version (7.0.1000.2)

    Am I such an C# dummy or is NinjaTrader displaying some bug?

    Regards,

    Edit: Well, it turns out I'm such a dummy. The following code doesn't generate any errors in the NinjaTrader log, though I'm wondering why the default constructor isn't provided by the compiler:
    PHP Code:
    class MoneyManagement2 : Strategy
    {
        protected double accountSize;
    
        public MoneyManagement2(double accountSize)
        {
            this.accountSize = accountSize;
        }
    
        public MoneyManagement2() : base()
        {
    
        }
    }
    
    class FixedPercent2 : MoneyManagement2
    {
        private float fixedPercentage;
    
        public FixedPercent2(double accountSize, float fixedPercentage)
            : base(accountSize)
        {
            this.fixedPercentage = fixedPercentage;
        }
    
        public FixedPercent2() : base()
        {
    
        }
    } 
    
    Last edited by J_o_s; 03-03-2011, 06:04 AM. Reason: solved

    #2
    J_o_s, happy to hear you got it working for you, since this is more a C# topic we could unfortunately not provide direct support for it, but I feel this overview can help - http://www.yoda.arachsys.com/csharp/constructors.html

    Comment


      #3
      Unable to create instance of NinjaTrader.Indicator EMA

      Hello
      I'm also having trouble when applying an EMA indicator to my chart. Please advise

      World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.
      Last edited by babypowder; 10-20-2013, 12:09 PM.

      Comment


        #4
        Hello babypowder,

        Thank you for your post.

        Please send me your log and trace files for today so that I may look into what occurred.

        You can do this by going to the Control Center-> Help-> Mail to Support.

        Please place 'ATTN: Patrick - 445469' and please reference this thread in the body of the email: http://www.ninjatrader.com/support/f...ad.php?t=38969

        I look forward to your response.

        Comment

        Latest Posts

        Collapse

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