Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do you dynamically Add TF based your periods based on your GUI Timeframe

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

    How do you dynamically Add TF based your periods based on your GUI Timeframe

    I know you can't do this code below in the Initialize() area.

    How can I do a similar thing to do the same function?

    If in the GUI, I select 30 min chart, I want to add 30 min, 15 min and 10 min data streams.

    If in the GUI, I select 15 min chart, I want to add 15 min, 10 min and 5 min data streams.


    #region Initialize
    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    EntryHandling = EntryHandling.UniqueEntries;
    AllowRemovalOfDrawObjects =
    true; // Draw objects can be removed separately from the script

    // add the data series to calc on
    // Add(PeriodType.Minute, intraPeriodInMinutes);
    if (BarsPeriods[0].Id == "Day" && BarsPeriods[0].Value == "1")
    {
    Add(PeriodType.Day,
    1);
    Add(PeriodType.Minute,
    30);
    Add(PeriodType.Minute,
    15);
    }
    // else if (BarsPeriods[0].Id == "Minute" && BarsPeriods[0].Value == "30")
    // {
    // Add(PeriodType.Minute, 30);
    // Add(PeriodType.Minute, 15);
    // Add(PeriodType.Minute, 5);
    // }
    // else if (BarsPeriods[0].Id == "Minute" && BarsPeriods[0].Value == "15")
    // {
    // Add(PeriodType.Minute, 15);
    // Add(PeriodType.Minute, 10);
    // Add(PeriodType.Minute, 5);
    // }
    // else if (BarsPeriods[0].Id == "Minute" && BarsPeriods[0].Value == "10")
    // {
    // Add(PeriodType.Minute, 10);
    // Add(PeriodType.Minute, 5);
    // Add(PeriodType.Minute, 2);
    // }

    // Calculate on the close of each bar = false - we will be using intraday data
    CalculateOnBarClose = false;
    }
    #endregion

    #2
    Hi DaFish, unfortunately we cannot support dynamic series adding for scripts - what I would suggest doing is creating user defined inputs, so you can then use creating the Add() statements needed.

    Comment


      #3
      Hi Bertrand, thanks a lot. I figured that was my only option...

      There is no way to override what the GUI is selected is there?

      For example, if I have the following parameters to add the following TFs
      ShortTF - 15 min
      MediumTF - 30 min
      LongTF - Day

      and I want to override the GUI to only display 15 min chart so BarsInProgress == 0 is 15 min chart

      Please advise

      Comment


        #4
        You're welcome, if I follow you correctly, you would list adjust the primary bars that's the GUI chart would visualize?

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          You're welcome, if I follow you correctly, you would list adjust the primary bars that's the GUI chart would visualize?
          Yes, if my parameters on the ShortTF show 15 min as the primary, I don't want the user (me) to go and forget that if I select another TF, my chart won't work.

          Not a big deal if there is no way. I guess I would know when my system displays nothing. It just won't be intuitive for the user.

          Comment


            #6
            Thanks, yes correcting this primary would unfortunately not be possible with supported methods - yes you could detect this and put a DrawTextFixed on the chart to inform you changing of the series would be needed.

            An alternative, more advanced hint would be using C# SendKeys to 'type' via code on your chart to change the interval - imitating the regular feature that we have for non programmatic use.

            Comment

            Latest Posts

            Collapse

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