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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        87 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        106 views
        0 likes
        Last Post CarlTrading  
        Working...
        X