• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 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

      http://screencast.com/t/auAEBob33Q9
      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.
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Hanstanz, Today, 04:44 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by Newtrader101, Today, 10:31 AM
        0 responses
        4 views
        0 likes
        Last Post Newtrader101  
        Started by rwilliam, Yesterday, 03:55 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by RandanAL, Today, 09:05 AM
        0 responses
        4 views
        0 likes
        Last Post RandanAL  
        Started by cstern71, 09-02-2019, 10:30 AM
        4 responses
        64 views
        0 likes
        Last Post Lancer
        by Lancer
         
        Working...
        X