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

Ninjascript generated code isn't generated

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

    Ninjascript generated code isn't generated

    I have an indicator which compiles fine but isn't generating the bottom code that should automatically be generated by Ninja. A strategy can't see that indicator and I'm afraid that's the reason.

    The indicator is pretty simple and the only exotic stuff it has are:

    * Another class declared after the indicator class end: public class SupportClass { logic }
    * The use of generics declared at the top with: using System.Collections.Generic

    What could be the reason for this?

    #2
    savekad, if you move the script to a completely new file and then compile again - would the wrappers be added?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      That's exactly what I tried to do and the results are as follows:

      * If I copy all code, delete the indicator, compile a random indicator, create a new indicator with the same name, past the code and compile it - no wrapper

      * If I copy all code, delete the indicator, compile a random indicator, create a new indicator with the same name, compile it (wrapper created), paste the code instead of the default code (leaving the wrapper alone), compile it - wrapper still exists (was created at the first compilation of the default code).

      When there is a wrapper, I can see and access variables from a strategy but can't see any parameters the indicator is set to receive (when calling the indicator, there are no overloads available) and there should be more than 4 bools to pass.

      Comment


        #4
        I hope I explained it well but if not, the bottom line is: the logic is, for some reason, not invoking the wrapper creation.

        Comment


          #5
          Thanks savekad, any change to the outcome if you comment out your more 'exotic' code? Would you mind posting or emailing in your properties section of the code?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            I've tried to strip down everything I can and the wrapper wasn't created. I got left with an empty indicator and still - no wrapper. I then tried to create a new indicator and strip it too as well and noticed that the wrapper was also not created so there must be something that invoke the creation of the wrapper. What is the trigger for creating a wrapper? I bet that's what my indicator misses.

            The minimum code that did not invoked a wrapper creation:

            using System;
            using System.ComponentModel;
            using System.Diagnostics;
            using System.Drawing;
            using System.Drawing.Drawing2D;
            using System.Xml.Serialization;
            using NinjaTrader.Cbi;
            using NinjaTrader.Data;
            using NinjaTrader.Gui.Chart;

            namespace NinjaTrader.Indicator
            {
            public class AAtest : Indicator
            {
            protected override void Initialize()
            {
            Overlay = false;
            }
            protected override void OnBarUpdate()
            {
            }
            }
            }

            Comment


              #7
              Your indicator misses a property, please retry with something like this added -

              #region Properties
              /// <summary>
              /// </summary>
              [Description("Numbers of bars used for calculations")]
              [GridCategory("Parameters")]
              public int Period
              {
              get { return period; }
              set { period = Math.Max(1, value); }
              }
              #endregion
              BertrandNinjaTrader Customer Service

              Comment


                #8
                As funny as it might sound, no property, value or plot made the wrapper created.

                After some tests, I found out it was the [Description()] line that caused all the trouble. I've added it and the wrapper was fully created.

                Comment


                  #9
                  Thanks savekad, I was able to hit this scenario here as well and have let my developers know.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Cool. Btw, if that is something that shouldn't be like that, where will I be able to be updated about that?

                    Comment


                      #11
                      Updates / Fixes would be documented in our release notes - http://www.ninjatrader.com/support/h...ease_notes.htm

                      This item you ran into is on developments list to look into for our next major release though.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        No Magic Code generated at bottom of Indicator. Properties formatting? Or?

                        I am developing an Indicator that I want to use in a Strategy. Problem is that NinjaTrader is not generating the Magic Code at the bottom of my Strategy. I assume that Magic Code has to be there in order for my Strategy to display and utilize the Indicator's DataSeries for trigger trade entries...
                        I've been searching this forum for help, clues and a solution.
                        (a) I've read that removing NinjaTrader.Custom.DLL can resolve a corrupt system. No luck.
                        (b) I've started from a clean, virgin install of NinjaTrader. No luck.
                        (c) I've seen posts and responses from Ninjatrader staff suggesting the format of Properties code must be done a certain way. For example:

                        #region Properties
                        /// <summary>
                        /// </summary>
                        [Description("Numbers of bars used for calculations")]
                        [GridCategory("Parameters")]
                        public int Period
                        {
                        get { return period; }
                        set { period = Math.Max(1, value); }
                        }
                        #endregion


                        I've tried various versions of formatting and sequencing my Properties code. There are also other Properties code elements, such as:
                        [XmlIgnore()] and
                        [Browsable(true)] and
                        [Gui.Design.DisplayNameAttribute("Moving average type")]

                        My male intuition is that this aspect of Indicator code is very fussy. I'm thinking I don't have my Parameter code in the right sequence or wrong format or ???

                        Question 1: Do you have any documentation or guidance about how to format and code Properties code in the best way?

                        Question 2: What other things can prevent the Magic Code at the bottom of my Indicator from being generated? Your assistance would be greatly appreciated. Thank you.

                        Comment


                          #13
                          Hello Buckstar,

                          Thank you for your post.

                          You can find information on creating user defined parameters at the following link: http://www.ninjatrader.com/support/f...ead.php?t=5782

                          However, I would ask what the description of the class is set to. Does this string contain any '+' symbols? For example:
                          Code:
                          	[Description("Average Directional Movement Rating quantifies momentum change in the ADX. It is calculated by adding two values of ADX (the current value and a value n periods back), " + "then dividing by two. This additional smoothing makes the ADXR slightly less responsive than ADX. The interpretation is the same as the ADX; the higher the value, the stronger the trend.")]
                          	public class ADXR : Indicator
                          	{

                          Comment


                            #14
                            Using Indicator from Strategy. NT Code Generation for Indicators?

                            Thanks for your response. My Properties descriptions do_not contain any + (plus) symbols. I am still having problems with the NT Generation of code at the bottom of the Indicator. Please read on...

                            I did try to create a new Wizard generated Indicator with one Parameter. The NT Generated Code at the bottom was created. I copied the rest of my Indicator code into that new Indicator file. Recompiling often to resolve issues. My indicator compiles and works correctly. But, I noted that the NT Generated Code did not change, even when I added more Parameters.

                            My goal is to use my Indicator from a Strategy, setting constructor parameters. For example:
                            myIndicatorXYZ = IndicatorXYZ(param1, param2, param3, param4);
                            add(myIndicatorXYZ);

                            I have some questions about how to resolve the generation of NT Code at the bottom of my Indicators:

                            Q1: What do I have to do to get the NT Generated Code to update to reflect newly added Parameters?

                            Q2: Can I just delete the NT Generated Code and hope NT regenerated it correctly? That did not work, as I described in my previous post. Is this supposed to work? Suggestions?

                            Q3: Can I hard-code some of the parameters in my Indicator and set them in the Initialize() method? I've read some posts which talk about Initialize() being called multiple times and is not a reliable way to initialize variables in an Indicator. Can I use Initialize() for this?

                            Q4: How do I hard-code default values for my Parameters? I'd like to have the Indicator Properties Grid open with default values I've hard coded. Then I can set alternate values using the Properties Dialog.

                            Q5: Can I define multiple constructors for my Indicator? And then, per Q4, have certain Parameters already pre-set? How does the NT Generated Code get updated or does it not care about multiple constructors? In summary, can I define multiple constructors?

                            Thank you.

                            Comment


                              #15
                              Hello Buckstar,

                              Thank you for your response.
                              Originally posted by Buckstar View Post
                              Q1: What do I have to do to get the NT Generated Code to update to reflect newly added Parameters?
                              It should be adding the newly created user defined variables to the generated code.
                              Originally posted by Buckstar View Post
                              Q2: Can I just delete the NT Generated Code and hope NT regenerated it correctly? That did not work, as I described in my previous post. Is this supposed to work? Suggestions?
                              No, please do not delete this information.
                              Originally posted by Buckstar View Post
                              Q3: Can I hard-code some of the parameters in my Indicator and set them in the Initialize() method? I've read some posts which talk about Initialize() being called multiple times and is not a reliable way to initialize variables in an Indicator. Can I use Initialize() for this?
                              Originally posted by Buckstar View Post
                              Q4: How do I hard-code default values for my Parameters? I'd like to have the Indicator Properties Grid open with default values I've hard coded. Then I can set alternate values using the Properties Dialog.
                              When setting the variables in the #region Variables section you will set a default value, for example the following is taken from the APZ indicator in NinjaTrader:
                              Code:
                                      #region Variables
                                      // Wizard generated variables
                                          private double bandPct = 2; // Default setting for BandPct
                                          private int period = 20; // Default setting for Period
                              			private int newPeriod = 0;
                                      // User defined variables (add any user defined variables below)
                                      #endregion
                              Originally posted by Buckstar View Post
                              Q5: Can I define multiple constructors for my Indicator? And then, per Q4, have certain Parameters already pre-set? How does the NT Generated Code get updated or does it not care about multiple constructors? In summary, can I define multiple constructors?
                              I would not recommend defining multiple constructors for any indicator or strategy. I would recommend creating a separate copy of the indicator if you wanted to create another instance that has different default variables.

                              NT Generated Code will update when variables are added to the indicator strategy as defined in the information at the following link: http://www.ninjatrader.com/support/f...ead.php?t=5782

                              Can you provide your .cs file for review here? The NT Generated Code should be updating, however there have been cases where altering the string for the Description of the class has caused the NT Generated Code to not update.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cre8able, Today, 03:20 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post cre8able  
                              Started by Fran888, 02-16-2024, 10:48 AM
                              3 responses
                              47 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Started by martin70, 03-24-2023, 04:58 AM
                              15 responses
                              114 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by The_Sec, Today, 02:29 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              2 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X