• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Parameter Initialization Issues

  • Filter
  • Time
  • Show
Clear All
new posts

    Parameter Initialization Issues

    Don't know where to begin. It didn't seem this confusing in NT7 and I'm not sure if this is simply an obscure NT8 feature or a defect in the Beta.

    I would like to understand how indicator parameters and properties are initialized and specifically how it is different than in NT7.

    I've attached a test indicator AParamInitTest that illustrates 4 different approaches to defining some parameters and the impact.

    In the example, you will see that both LineBrush and LineDate properties do not have an associated (lower case) global parameter associated with them. Whereas, AreaBrush and AreaDate do.

    Is the initialization of AreaBrush and AreaDate consistent? Seems areaDate is set properly but in the case of areaBrush, not displayed in the Indicators Properties window on default.

    If the values of areaBrush and areaDate are not explicity set by the user,

    If AreaBrush and AreaDate (notice upper case) are gets and sets of the private lower case variables, why are the values different between on State.Default and State.Configure and why is there an error on State.Terminated if not explicitly set by the user?

    Are the sequence of events and printed values as expected and make sense?

    Is there any documentation on good programming practices for how and why to define a property in a particular way?
    Attached Files


    Thank you for the questions.

    There is nothing special happening with properties in NT8, mainly you would just need to follow standard C# public property syntax.

    I do see some inconsistencies across the properties here, as a general rule if you need a public property it can just be a {get;set;} without a backing field in most cases. You would then use the Public property everywhere in the file and also Set the public property default value from State.SetDefaults.

    For more complex properties or items that require serialization like a Brush, you would use a backing field per the example here: http://ninjatrader.com/support/forum...43&postcount=2

    One of the items I see in the file is with AreaBrush specifically and how it is not currently linked to the backing field.

    In the case of using only
    { get; set; }
    You have only one instance of the property at this point,so you would need to call the public property only. for example in the use of :

    public SolidColorBrush AreaBrush { get; set; }
    This has no private backing field associated with the get; set; so everywhere in the script you use this or set it, it should be called as AreaBrush.

    In State.SetDefaults you print the private variable instead of the above property which is in no way linked to the public property. If you enter a value in the user interface, this would not effect the areaBrush property because the UI is using the public property AreaBrush, you are printing the property areaBrush so the output should always be Brushes.White or what you defined.

    For the AreaBrush property specifically, I would suggest reviewing the above link on serializing brush properties as it includes the most used and accepted syntax in the platform.

    For other simple properties, a {get;set} is often all that is needed and to use the Public property in the script.

    There is a simple explaination of auto properties {get;set;} VS. backing fields properties here: http://csharp.net-tutorials.com/csha...ic-properties/

    The way I like to think of which to use would be: Do I need to do any logic while getting or setting this value? if no use an auto property {get;set;} if yes, use a backing field where you have a method body for both the get and set you can execute logic in.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service


    Latest Posts


    Topics Statistics Last Post
    Started by teafortwo, Today, 04:26 AM
    4 responses
    Last Post bltdavid  
    Started by borjanews, Today, 06:13 PM
    0 responses
    Last Post borjanews  
    Started by Austiner87, Today, 05:13 PM
    0 responses
    Last Post Austiner87  
    Started by Austiner87, Today, 04:59 PM
    0 responses
    Last Post Austiner87  
    Started by Austiner87, Today, 04:58 PM
    0 responses
    1 view
    Last Post Austiner87