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

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 accountSizefloat 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 accountSizefloat 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
    BertrandNinjaTrader Customer Service

    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

      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 Irukandji, Yesterday, 02:53 AM
        2 responses
        17 views
        0 likes
        Last Post Irukandji  
        Started by adeelshahzad, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post adeelshahzad  
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        3 views
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Working...
        X