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

Input BarsPeriod on Custom BarTypes

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

    Input BarsPeriod on Custom BarTypes

    Hello,

    I'm not sure if this is expected behavior or a bug. I added an input to an indicator as defined below.

    Code:
            private BarsPeriod iMtfBars1 = new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, BarsPeriodTypeName = Custom.Resource.BarsPeriodTypeNameMinute, Value = 1 };
            [NinjaScriptProperty]        [Display(Name = "01. MTF BarType Selection", Description = "MTF TimeFrame Bar parameters", GroupName = "bMtfParameters", Order = 1)]
            public BarsPeriod MtfBars1 
            {
                get { return iMtfBars1; }
                set { iMtfBars1 = value; }
            }
    When using this input the bartype input names will show as their code variables names are, such as (Value, Base period type, Base period value). For example, a Renko chart will show Value.

    However, when I create a chart using the bartype, the names are as I would expect. For example, a Renko chart will show Brick size (rather than Value).

    I'm not sure if this is an error, or expected. I would expect the inputs to show as the same regardless as to where you're pulling them from.

    Thank you in advance
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    #2
    Hello mrlogik,

    The BarsPeriod is not an object that was intended to be exposed as a public property and does not work with the NinjaScriptProperty attribute tag.

    Instead, you could make a BarsPeriodType object, and then construct a new BarsPeriod object in OnStateChange.
    Code:
    [NinjaScriptProperty]
    public BarsPeriodType BarsPeriodTypeSelection
    { get; set; }
    
    [Range(1, int.MaxValue)]
    [NinjaScriptProperty]
    public int BarsPeriodValueSelection
    { get; set; }
    Code:
    protected override void OnStateChange()
    {
    	if (State == State.SetDefaults)
    	{
    		BarsPeriodTypeSelection		= BarsPeriodType.Minute;
    		BarsPeriodValueSelection		= 5;
    	}
    	else if (State == State.Configure)
    	{
    		BarsPeriod barsPeriod = new BarsPeriod()
    		{
    			BarsPeriodType			= BarsPeriodTypeSelection,
    			BaseBarsPeriodValue 		= BarsPeriodValueSelection
    		};
    	}
    }
    If you wanted to make your own custom class to wrap the two properties in, you could do this. Attached is an example script I've made that demonstrates a custom class as an expandable property.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea, much appreciated.
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by gentlebenthebear, Today, 01:30 AM
      2 responses
      13 views
      0 likes
      Last Post gentlebenthebear  
      Started by Kaledus, Today, 01:29 PM
      2 responses
      8 views
      0 likes
      Last Post Kaledus
      by Kaledus
       
      Started by frankthearm, Yesterday, 09:08 AM
      13 responses
      46 views
      0 likes
      Last Post frankthearm  
      Started by PaulMohn, Today, 12:36 PM
      2 responses
      16 views
      0 likes
      Last Post PaulMohn  
      Started by Conceptzx, 10-11-2022, 06:38 AM
      2 responses
      56 views
      0 likes
      Last Post PhillT
      by PhillT
       
      Working...
      X