Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      574 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      333 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X