Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need to refresh chart programmatically after interval change?

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

    Need to refresh chart programmatically after interval change?

    Is it possible to refresh a chart programmatically so it displays the bars with the new interval setting accomplished by the following C# code in my strategy?: BarsPeriod.Value = 3. The only way I have accomplished the interval update in the chart after the above code is executed is to manually "Reload Historical Data" 2 times from the chart window's right click/context menu.

    After right clicking the chart and selecting "Reload Ninja Script", the chart window refreshes, the chart window's title bar reflects the new interval but the chart's bars don't reflect the new interval. There is no change. If I then right click chart, select "Reload Historical Data", the bars do update.

    Otherwise, if I haven't selected "Reload NinjaScript", the only way to get the chart to reflect the new interval is to right click the chart, select "Reload Historical Data" 2 times. Not 1 time. It has to be 2 times. The chart's title bar does reflect the changed interval after "Reload Historical Data" happens the 1st time. The chart bars don't update until after the 2nd selection of "Reload Historical Data".

    #2
    Hello aaScotty,

    Unfortuantely this is not supported. The only supported way of changing a charts interval is using the GUI options.
    • On the chart toolbar
    • Through Right Clicking > Format Data Series
    • Right Clicking > Interval

    NT7 will offer an additional way through keystrokes.

    Enhanced Command Line Driven Chart Changing
    Currently, you can directly type a new instrument symbol in a chart to change the data series. We have enhanced this by providing command line access to change the interval also.
    For example:
    - Type "3m" to change to a 3 minute chart
    - Type "MSFT 3m" to change to MSFT 3 minute chart
    - Type "1000t" to change to 1000 tick chart
    - Type "8r" to change to a 8 tick range chart
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      There is an unsupported method which I have used for dynamically creating DataSeries in OnBarsUpdate(), You can then set the new series as your primary or even switch to and fro.

      PeriodType ID = BarsPeriod.Id;
      Add(ID,NewPeriod);
      Last edited by Sleeping Troll; 04-17-2010, 11:08 AM.

      Comment


        #4
        Have you found a clean way to do this?

        I'm trying to change the interval on the chart programatically (without any manual reloads of the chart, etc).

        I tried the Add() call in OnBarUpdate() you mentioned and I get an error that it can only be called within Initialize().

        I tried putting it in Initialize(), but I'm struggling to get that to work the way I want.

        Anyone find some success with this? Ultimately, I am trying to create my own, custom drop down of intervals. I've created drop downs before, so I just need this missing piece!

        Thanks!
        Daniel

        Comment


          #5
          Hi Daniel,

          We can only support the NinjaScript items within our help guide, and unfortunately there's no supported technique for changing bar interval programatically. We have received requests for dynamic series adding in code, and I'm happy to add your vote in for this as well. Thanks for posting.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by neoikon View Post
            Ultimately, I am trying to create my own, custom drop down of intervals. I've created drop downs before, so I just need this missing piece!
            So, I'll answer my own question. I figured out how to add values to the intervals drop down, including all interval types, even including adding an instrument/interval pair as well. Turned out perfect!

            PM for info on it.



            Daniel

            Comment


              #7
              We are looking at how to refresh the chart programatically.. any tips?

              We have button code up and running there.




              Originally posted by neoikon View Post
              So, I'll answer my own question. I figured out how to add values to the intervals drop down, including all interval types, even including adding an instrument/interval pair as well. Turned out perfect!

              PM for info on it.



              Daniel

              Comment


                #8
                Originally posted by NinjaTrader_RyanM View Post
                Hi Daniel,

                We can only support the NinjaScript items within our help guide, and unfortunately there's no supported technique for changing bar interval programatically. We have received requests for dynamic series adding in code, and I'm happy to add your vote in for this as well. Thanks for posting.

                Please add my name to the list of users requesting this feature.

                Comment


                  #9
                  Originally posted by Crassius View Post
                  Please add my name to the list of users requesting this feature.
                  follow the link in my recent post in this thread and see what NT_Joydeep has posted as a work around.

                  Comment

                  Latest Posts

                  Collapse

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