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

Adding Higher Timeframe in indicator

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

    Adding Higher Timeframe in indicator

    I would like to add a higher timeframe input series to an indicator. I am looking of a way to create a property for the series definition, and how to use it to create the input. Is there any example I could see how it's done?

    #2
    Hello Shai Samuel,

    Thank you for your post.

    The supported and documented way to do this would be to not use a input picker and hard code the series by adding that series: http://ninjatrader.com/support/helpG...=adddataseries.

    In theory, you could recreate an input picker using the following syntax. Please note that this does not necessarily apply the series in the same way as the original input picker does so there are unknown consequences by using the following syntax as it is not documented. You would need to test and see if this can or will work for what you want to do.

    Code:
    [Display(Name = "MyInput", Prompt = "Pick MA Series!", Order = 99)]
    [PropertyEditor("NinjaTrader.Gui.Tools.InputEditor" )]
    [XmlIgnore] public ISeries<double> MyInput
    { get; set; }
    I can then use the following syntax to access values, again please keep in mind this is not documented or expected to work correctly. I am unsure of any sync issues that could arise from the use of this code.

    Code:
    protected override void OnBarUpdate()
    {
    Print(Close.GetValueAt(Count - CurrentBar) + " " + MyInput.GetValueAt(Count - CurrentBar));
    }
    Please let us know if this does not resolve your inquiry.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate, thank you for the quick reply. When I open in the Indicator UI the "NinjaTrader.Gui.Tools.InputEditor" field, I get a dialog which looks like it was not setup properly (see the image on the left):
      • The Available list only the default instruments
      • The folder that shows up is "Indicators", and not BarTypes as I would expect
      • The only change you could do to an exiting series, is to change the price type
      Click image for larger version  Name:	Screen Shot 2022-06-30 at 7.12.55 AM.png Views:	0 Size:	78.8 KB ID:	1207073Click image for larger version  Name:	Screen Shot 2022-06-30 at 2.14.00 PM.png Views:	0 Size:	925.8 KB ID:	1207092

      Here are my questions?
      1. Is something missing in my system? I did expect something like the "Data Series" (the image on the right), that is available in Indicators, maybe without the option to choose the instrument
      2. Clearly I am looking for a way to offer the use to define the other timeframe period. So alternatively, if I use BarsTypePeriod as a property, its doesn't include custom barTypes.
      3. I also saw a way to get all types using NinjaTrader.Core.Globals.AssemblyRegistry.GetDeriv edTypes(typeof(BarsType)), but I am not clear how I can translate this into a dropDown menu that can be used as property.

      Code:
      Type[] types = NinjaTrader.Core.Globals.AssemblyRegistry.GetDerivedTypes(typeof(BarsType));
      for (int i = 0; i < types.Length; i++)
      {
        Type type = types[i];
        if (type == null || type.FullName.IsNullOrEmpty()) continue;
        var type2 = NinjaTrader.Core.Globals.AssemblyRegistry.GetType( type.FullName);
        if (type2 == null) continue;
        BarsType bar = Activator.CreateInstance(type2) as BarsType;
        if (bar != null)
        {
          bar.SetState(State.SetDefaults);
          int id = (int)bar.BarsPeriod.BarsPeriodType;
          Print(string.Format("{0} - {1}", bar.Name, id,id));
          bar.SetState(State.Terminated);
        }
      }
      Last edited by Shai Samuel; 06-30-2022, 06:10 AM.

      Comment


        #4
        Hello Shai Samuel,

        Thank you for your reply.

        As I mentioned previously, the above code is undocumented, which means it's not supported. The supported and documented way to add a data series would be to hard code it using AddDataSeries. Adding data series dynamically is unsupported and may result in errors.

        As far as NinjaTrader.Core.Globals.AssemblyRegistry.GetDeriv edTypes(typeof(BarsType)), this would be undocumented and unsupported.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ct, 05-07-2023, 12:31 PM
        6 responses
        202 views
        0 likes
        Last Post wisconsinpat  
        Started by kaywai, Today, 06:26 AM
        0 responses
        1 view
        0 likes
        Last Post kaywai
        by kaywai
         
        Started by kevinenergy, 02-17-2023, 12:42 PM
        118 responses
        2,778 views
        1 like
        Last Post kevinenergy  
        Started by briansaul, Today, 05:31 AM
        0 responses
        9 views
        0 likes
        Last Post briansaul  
        Started by traderqz, Yesterday, 12:06 AM
        11 responses
        28 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X