Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

User inputs -- manually created (not via wizard)

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

    User inputs -- manually created (not via wizard)

    I am attempting to create variables that are user settable inputs, basically so I can attempt optimization with a wide range of values. Am having a problem with a script that I am editing manually. my programming background is limited, so please help.

    I manually added the variable in #region variables like this:

    private
    int BollThresh = 20;

    and added a reference in #region properties near the end of the file like this.

    [Description("")]
    [Category(
    "Parameters")]
    publicint BollThresh
    {
    get { return BollThresh; }
    set { BollThresh = Math.Max(1, value); }
    }


    But the compiler does not like seeing both present. It barks at the properties entry and says "The type 'NinjaTrader.Strategy.LongHammerTrailingStop' already contains a definition for 'BollThresh' Strategy\LongHammerTrailingStop.cs 83 12."

    But if I omit the properties entry (which compiler passes the run with), then I won't see the variable listed as an adjustable option.

    Note that this code file doesn't have the Wizard XML at the end of it. Is this absolutely necessary to create user input variables? Does that require I create a hollow shell with my named variables the wizard that creates the XML, that I then paste my procedures in?

    Any quick and fast workarounds for nonwizard work?


    #2
    The problem is that you are declaring a property with the exact same name as a variable. Try changing your code to what I have written below. Notice the difference in case. The variable is "bollThresh" while the property is "BollThresh".

    Code:
    private int bollThresh = 20;
    
    [Description("")]
    [Category("Parameters")]
    public int BollThresh
    {
        get { return bollThresh; }
        set { bollThresh = Math.Max(1, value); }
    }
    RayNinjaTrader Customer Service

    Comment


      #3
      Thank you very much. very useful. now i'm not dependent on the wizard.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by sjsj2732, Yesterday, 04:31 AM
      0 responses
      35 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      287 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      286 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      133 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      92 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X