Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Allow user to select an indicator+plot as a indicator parameter

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

    Allow user to select an indicator+plot as a indicator parameter

    Hi NinjaTrader


    I have an indicator that has the need that the user can select another indicator + plot as one of its parameters
    (Note that I know we can nest indicators by selecting it via the indicators Input series but that's not what I want)
    The indicator should just have the normal data series as its input and allow the user to select another indicator as one of its parameters
    Then I want to use the plot of this user-selected indicator from within my own indicator

    Hope this makes sense :-)

    I tried something like this, but that doesn't work

    Code:
    [Display(ResourceType = typeof(Custom.Resource), Name = "Indicator",)]
    public Series<double> SomeIndicator { get; set; }


    EB Worx
    NinjaTrader Ecosystem Vendor - EB Worx

    #2
    Hello EB Worx,

    Thank you for your reply.

    There's not really a good way to do that, unfortunately.

    Even if you get the indicator itself from a user input you will have to still instantiate the indicator so you would need to know their input parameters to write a constructor for each indicator that could possibly be selected, and there will be a different number of inputs with each indicator.

    You could make enums like SampleUniversalMovingAverage (attached below) and have those set up logic for specific indicators that you choose, but having an input grab an indicator like what you're trying isn't really feasible. We've tried some approaches with InputEditor on our end of things in the past but found there were issues backtesting where it does not work well at all.

    I would suggest narrowing down the indicators to be supported and taking the approach in the attached example.

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment


      #3
      Thanks for your answer. Choosing an indicator from a fixed list is not what I want. I want the user to choose any indicator
      I found this piece of code on the forum, however somehow its not providing the correct values for me
      If I could this to work then that would be great. If backtesting would not work then that's ok

      Code:
      //This namespace holds Indicators in this folder and is required. Do not change it.
      namespace NinjaTrader.NinjaScript.Indicators
      {
        public class SampleIndicatorInput : Indicator
       {
        protected override void OnStateChange()
        {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "SampleIndicatorInput";
      Calculate = Calculate.OnBarClose;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      InputIndicator1 = null;
      }
      else if (State == State.Configure)
      {
      }
      }
      
      double myValue;
      protected override void OnBarUpdate()
      {
      Print(InputIndicator1.Name);
      
      switch(InputIndicator1.Name){
      case "SMA":
      SMA settingsSma = (SMA) InputIndicator1;
      myValue =SMA(settingsSma.Period)[0];
      Print(myValue);
      break;
      }
      
      }
      
      
      [Display(Name = "Indicator 1", GroupName = "Parameters", Prompt = "Edit indicator 1...", Order = 0)]
      [PropertyEditor("NinjaTrader.Gui.Tools.InputEditor" )]
      [XmlIgnore]
      public Indicator InputIndicator1 { get; set; }
      
      }
      }
      EB Worx
      NinjaTrader Ecosystem Vendor - EB Worx

      Comment


        #4
        Hello EB Worx,

        Thank you for your reply.

        That's exactly what I'm referring to with InputEditor and you won't get very far with that as you would still need to instantiate the indicator. Which means you would need to know their input parameters to write a constructor for each indicator that could possibly be selected, and there will be a different number of inputs with each indicator. The amount of logic necessary for this isn't really feasible and we've not found a way to do this that will reliably work in backtests. Your best bet is to narrow down the number of indicators that can be selected to a specific number of indicators and use the approach found in the example in my prior posts.

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Thanks for the quick response,
          but then how is Bloodhound from SharkIndicators doing this ? via reflection ?
          EB Worx
          NinjaTrader Ecosystem Vendor - EB Worx

          Comment


            #6
            Hello EB Worx,

            Thank you for your reply.

            Possibly, however, we don't have access to their code, and using reflection for something like this is far outside the scope of what would we can support.

            Please let us know if we may be of further assistance to you.

            Comment


              #7
              Ok, well thanks anyway. time for me to do some digging :-)
              EB Worx
              NinjaTrader Ecosystem Vendor - EB Worx

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              571 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              330 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
              548 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              548 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X