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

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 Perr0Grande, Today, 08:16 PM
      0 responses
      2 views
      0 likes
      Last Post Perr0Grande  
      Started by elderan, Today, 08:03 PM
      0 responses
      5 views
      0 likes
      Last Post elderan
      by elderan
       
      Started by algospoke, Today, 06:40 PM
      0 responses
      10 views
      0 likes
      Last Post algospoke  
      Started by maybeimnotrader, Today, 05:46 PM
      0 responses
      12 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      7 views
      0 likes
      Last Post quantismo  
      Working...
      X