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 Trader146, Today, 09:17 PM
      0 responses
      4 views
      0 likes
      Last Post Trader146  
      Started by ttrader23, 05-08-2024, 09:04 AM
      9 responses
      43 views
      0 likes
      Last Post ttrader23  
      Started by ZeroKuhl, Yesterday, 04:31 PM
      8 responses
      46 views
      0 likes
      Last Post ZeroKuhl  
      Started by reynoldsn, Today, 07:04 PM
      0 responses
      11 views
      0 likes
      Last Post reynoldsn  
      Started by puapwr, Today, 06:09 PM
      0 responses
      5 views
      0 likes
      Last Post puapwr
      by puapwr
       
      Working...
      X