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

Parameters, functional and just visual

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

    Parameters, functional and just visual

    Hello polite people! Hope you having a great week!

    I'm learning staff with the pass of the time...

    And I would like to customize my parameters.

    I can't find in any code like, "optional" values. Example, i want to put a GroupName for "Lines", and that's just visual. I don't want it to ask me everytime about "Lines", which i won't use if it's pure code and nothing visual.

    For example:
    ind = Indicator(5);
    Code:
    [NinjaScriptProperty]
    		[Display(Name = "Period", Order = 1, GroupName = "01. Parameters")]
    		public int Period
    		{ get; set; }
    but it actually has..

    Code:
    [NinjaScriptProperty]
    		[Display(Name = "Period", Order = 1, GroupName = "01. Parameters")]
    		public int Period
    		{ get; set; }
    
    [NinjaScriptProperty]
    		[Display(Name = "UpperLine", Order = 2, GroupName = "02. Lines")]
    		public int Upper
    		{ get; set; }
    
    [NinjaScriptProperty]
    		[Display(Name = "LowerLine", Order = 3, GroupName = "02. Lines")]
    		public int Lower
    		{ get; set; }
    so.. i want to fill Indicator(5, 70, 30) just when i'm in a chart.

    I hope you can help me.
    Thanks for your time.
    Last edited by Fernand0; 06-12-2018, 09:29 PM.

    #2
    Hello Fernand0,

    Thanks for your post.

    I'm not entirely certain I understand what you are asking for but I think you are wanting to set the default values for the variables to 5, 70, 30.

    To set the default values, in the OnStateChange() inside of State.SetDefaults you would add:

    Period = 5; //default value
    Upper = 70; // default value
    Lower = 30; // default value.

    This would set the defaults so that when you apply the indicator these values would be populated and you could still change them if you wanted to.


    If you are asking to prevent the Upper and Lower values from being changed or are asking not to display the values at all, then what you can do is to create them as private variables at the class level and remove the public properties. For example:

    public class Fernando: Indicator
    {
    private int Upper = 70; // default value
    private int Lower = 30; // default value

    protected override void OnStateChange()


    You would then in this case not set the values in State.SetDefaults as you have already declared and assigned their defaults. You would also remove the Public properties as they are not needed.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      No, those are not the cases.

      I want to create another class constructor, but by default, NT creates them so, all code is erased an recreated.

      When you have several constructors... you don't need to specify all the arguments

      public _constructor(int P, int P2) { ... } <--- I want this for coding
      public _constructor(int P, int P2, int P3, int P4) { ... } <--- And I want this for charting
      public _constructor(int P, int P2, int P3, int P4, int P5 = 0, P6 = 100) { ... } <--- this is just another example

      the second constructor has P3 and P4 that only works to put lines in the chart.. just visual things
      imagine that in coding strategies, i don't need to draw lines, i don't need visual things, i just need the values of the Plots

      I hope i made myself more clear
      Last edited by Fernand0; 06-13-2018, 08:29 AM.

      Comment


        #4
        Hello Fernand0,

        Thanks for your reply and clarification.

        No, you cannot have multiple constructors as the Ninjascript generated code will overwrite the custom overloads. There is no workaround for this.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Look at the code at the bottom of each indicator. The code that says
          NinjaScript generated code. Neither change nor remove.
          Those are your indicator constructors. You can add your own there BUT BEWARE. You must do this carefully so you don't mess up your indicator script.

          Comment


            #6
            Thank you both.

            It's a shame because this way i would have to make 2 indicators.. 1 for coding.. and 1 for visual...

            Unless.... hum.... i make it dynamic... https://mobile.ninjatrader.com/suppo...16&postcount=4

            I will check that out, so with one boolean i can display the Visual parameters (i don't know if i have to fill them anyway in the constructor)


            Have a nice day!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by funk10101, Today, 09:43 PM
            0 responses
            6 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            37 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Yesterday, 08:51 AM
            8 responses
            44 views
            0 likes
            Last Post bill2023  
            Started by yertle, Today, 08:38 AM
            6 responses
            26 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            24 views
            0 likes
            Last Post algospoke  
            Working...
            X