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 RookieTrader, Today, 09:37 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by kulwinder73, Today, 10:31 AM
      0 responses
      7 views
      0 likes
      Last Post kulwinder73  
      Started by terofs, Yesterday, 04:18 PM
      1 response
      24 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by CommonWhale, Today, 09:55 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Gerik, Today, 09:40 AM
      2 responses
      8 views
      0 likes
      Last Post Gerik
      by Gerik
       
      Working...
      X