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

Indicator Overloaded Constructor Problem

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

    Indicator Overloaded Constructor Problem

    Hi Guys,

    My Questions:
    (Note: I'm using the term autogenerate, this is what I am calling the NinjaScript process of automatically adding additional c# code to the end of the indicator after compiling the indicator).
    1. Why doesn't the indicator autogenerate an overloaded constructor?
    2. What is the proper way to compile NinjaScript indicator and have it recognize the overloaded constructor and autogenerate correctly?

    Problem: My strategy does not recognize my custom Indicator with an overloaded constructor.

    Error Message
    "No Overload for method 'MyIndicator' takes '4' arguments." - this is on compiling MyStrategy (Pseudo code below)

    Trial and Error
    I deleted and recreated both the indicator and the strategy, same error.

    My thoughts:
    - I have an indicator that has an overloaded constructor but I can't get my strategy to recognize the new constructor with 4 arguments.
    -Although my indicator has an overloaded constructor, it is not in the auto generated ninjascript REGION at the end of the indicator. (the "region NinjaScript generated code. Neither change nor remove" )

    My Pseudo code

    My Indicator
    namespace NinjaTrader.Indicator
    {

    Public Class MyIndicator : Indicator
    {
    private int field1;
    private int field2;
    private int field3;
    private int field4;

    Public MyIndicator (int x_param1, int x_param2, int x_param3, int x_param4)
    {
    this.field1 = x_param1;
    this.field2 = x_param2;
    this.field3 = x_param3;
    this.field4 = x_param4;
    }

    }
    }

    MyStrategy
    namespace NinjaTrader.Strategy
    {
    Public Class MyStrategy : Strategy
    {
    private int field1 = 1;
    private int field2 = 2;
    private int field3 = 3;
    private int field4 = 4;

    protected override void Initialize()
    {
    base.Add(MyIndicator(this.field1,this.field2,this. field3,this.field4));
    }

    }
    }
    Last edited by FattMatt4088; 08-07-2013, 06:15 AM.

    #2
    FattMatt4088, what happens if you remove the autogenerated NS wrappers section and then recompile your script? It should regenerate the wrappers then for you.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,
      Thanks for the tip, I followed your advice and I still do NOT see my overloaded constructor in the autogenerated code. I moved the NT Region down a 3 lines, and recompiled. Seems a bit buggy to me.

      Comment


        #4
        Thanks for sharing the update, would you perhaps an example script you see issues with you could forward to us at support at ninjatrader dot com?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks for your help Bertrand, I figured it out.

          Original Problem: Ninjatrader is not autogenerating an overloaded constructor


          Solution Summary:
          Add "#region Variables" around the class fields and changed the parameter attributes to the below code.

          Detailed Solution:
          1. Add "#region Variables" to the top of the code around your fields.
          2. Make sure your parameter attributes are as follows:
          Correct:
          [Description("YourDescription")]
          [GridCategory("Parameters")]

          Incorrect:
          [Description("YourDescription"), Category("Parameters")]
          Last edited by FattMatt4088; 08-07-2013, 09:01 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kempotrader, Today, 08:56 AM
          0 responses
          6 views
          0 likes
          Last Post kempotrader  
          Started by kempotrader, Today, 08:54 AM
          0 responses
          4 views
          0 likes
          Last Post kempotrader  
          Started by mmenigma, Today, 08:54 AM
          0 responses
          2 views
          0 likes
          Last Post mmenigma  
          Started by halgo_boulder, Today, 08:44 AM
          0 responses
          1 view
          0 likes
          Last Post halgo_boulder  
          Started by drewski1980, Today, 08:24 AM
          0 responses
          4 views
          0 likes
          Last Post drewski1980  
          Working...
          X