Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Input Series at Run time

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

    Custom Input Series at Run time

    Hi,

    I have an indicator in which the user selects from one of several options. Lets call them a, b, or c. Depending on the option selected, I would like to associate a different IDataSeries with a custom series I call input. I would like to use the following in the OnStartUp():

    switch (inputValue)
    {
    case a:
    input = Open;
    break;
    case b:
    input = 0.273 *(High - Low) + 0.333;
    break;
    case c:
    input = Open/Low;
    break;
    default: // no action required
    break;
    }

    This way I could simply use the variable (series) input in my code. I know about the Input series that is already available but I am looking to assign custom series rather than the PriceType supported.

    Any suggestions would be greatly appreciated. Thank you.

    #2
    Hello Zeos6,

    Thank you for your post.

    Together with your switch you could just assign the custom series to a DataSeries and not need to necessarily use IDataSeries, for example:
    Code:
    switch (inputValue)
    {
    case a:
    mySeries.Set(Open[0]);
    break;
    case b:
    mySeries.Set(0.273 *(High[0] - Low[0]) + 0.333);
    break;
    case c:
    mySeries.Set(Open[0]/Low[0]);
    break;
    default: // no action required
    mySeries.Set(Input[0]);
    break;
    }
    Then you can call your series as you would Close or Open with a bars index.

    For information on DataSeries Class in NinjaTrader please visit the following link: http://www.ninjatrader.com/support/h...ries_class.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Thank you for your reply. The issue though is that I want to do this once only in OnStartUp() . In other words, the user selects option a and I would want input to be assigned as say Open and then simply use input in OnBarUpdate(). Your code will not achieve that. It would work if it were done in the OnBarUpdate() but that would mean calling the switch statement on every bar and I am trying to avoid that. I am trying to do what you already do with the Input series but I want to use my custom values rather than the price types you have.

      Comment


        #4
        Hello Zeos6,

        Thank you for your response.

        I could only see using a variable in that case but you would still need to check the variable:
        Code:
        		protected override void OnStartUp()
        		{
        			switch (inputValue)
        			{
        			case a:
        			mySeriesSelect = 0;
        			break;
        			case b:
        			mySeriesSelect = 1;
        			break;
        			case c:
        			mySeriesSelect = 2;
        			break;
        			default: // no action required
        			mySeriesSelect = 3;
        			break;
        			}
        		}
        
        		protected override void OnBarUpdate()
        		{
        			if(mySeriesSelect == 0)
        				mySeries.Set(Open[0]);
        			else if(mySeriesSelect == 1)
        				mySeries.Set(0.273 *(High[0] - Low[0]) + 0.333);
        			else if(mySeriesSelect == 2)
        				mySeries.Set(Open[0]/Low[0]);
        			else if(mySeriesSelect == 3)
        				mySeries.Set(Input[0]);				
        		}

        Comment


          #5
          Thank you. I know how to do what you suggested. I was simply wondering if there was a way of assigning a series to a custom series in the OnStartUp(). Apparently there is not a way. Thank you for your suggestions.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          600 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          346 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          558 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          558 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X