Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto scaling of the Chart Panel?

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

    Auto scaling of the Chart Panel?

    Is it possible to get an indicator to automatically control the zooming of the chart.

    e.g.

    Code:
    protected override void OnBarUpdate()
    { 
    double newMax = customdoublehigh;
    double newMin = customdoublehigh;
    ChartPanel.SetYScale(newMin, newMax); //
    }
    or

    something like
    Code:
    ChartPanel.ScaleMax = newMax;
    ChartPanel.ScaleMin = newMin;
    So far I've had no success, but I thought I'd ask if there was a known way to do this.

    Basically I want to problem an indicator to keep track of the high and low of a specific time period and keep the chart optimised for that,
    and I want to run it on numerous different charts so they all behave the same way.

    Thank you for your time,
    David.

    #2
    Hello David,

    Thank you for your post.

    If a script has IsAutoScale set to true in State.Defaults or State.Configure, then it will call OnCalculateMinMax() which determines the highest and lowest value used for the chart scale. Indicators have IsAutoScale set to true by default. For more information:You should be able to override OnCalculateMinMax() if desired to set MinValue and MaxValue based on the high and low for a specific time period.

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

    Comment


      #3
      Thank you for your help, NinjaTrader_Emily,
      but is there a sample indicator somewhere? I can not get a forced zoom in automatically with each onbarupdate.

      I'm even calling OnCalculateMinMax() in OnBarUpdate and using Printoutputs.

      Code:
           Print("OnCalculateMinMax() executed" + "  " + MinValue + "  " + MaxValue);
      It just doesn't do anything....

      Comment


        #4
        Hello davydhnz,

        Thank you for your reply.

        OnCalculateMinMax() is an event-driven method that is called outside of OnBarUpdate(). It is called when the chart scale is updated. As mentioned on the help guide page, the syntax is an override that you can add to your script:
        You must override the method in your NinjaScript object with the following syntax:

        public override void OnCalculateMinMax()
        {

        }
        My colleague has created a test script that adds a print inside of OnCalculateMinMax() here:
        OnCalculateMinMax() has also been discussed in the following thread, where a user tried to use the method to set the range between 68.50 and 74.00:
        Hopefully the test script from the first link and the snippet from the second link help to understand how OnCalculateMinMax() functions. Here is the help guide link again just in case you would like to review the snipped on the help guide page as well:Please let me know if I may be of further assistance.

        Comment


          #5
          Hi NinjaTrader_Emily,

          thank you for the reply and the sample script!
          It was most helpful.


          After some experimentation I got it working as intended for the data series,
          but is there any way to force a certain bar time to remain visible on the chart?

          e.g. bar at 2am must remain on the far left side of the screen,
          and with every additional bar, the screen bunches up and gets smaller until hour 4am?

          Thank you very much again!

          Comment


            #6
            Originally posted by davydhnz View Post
            Hi NinjaTrader_Emily,

            thank you for the reply and the sample script!
            It was most helpful.


            After some experimentation I got it working as intended for the data series,
            but is there any way to force a certain bar time to remain visible on the chart?

            e.g. bar at 2am must remain on the far left side of the screen,
            and with every additional bar, the screen bunches up and gets smaller until hour 4am?

            Thank you very much again!
            There is currently no way to force a certain bar/time to remain visible on the chart. That said, I have submitted this as a feature request to the Development Team for future consideration. I will follow up with an internal tracking number for your reference as soon as it is created.

            Thanks in advance for your patience.

            Comment


              #7
              Hello davydhnz,

              Thanks for your patience.

              The internal tracking number for your feature request is SFT-6049. Please reference this internal tracking number when contacting Platform Support if you ever have questions regarding this feature request.

              When a feature request is implemented, you'll find a description of the new feature in the release notes:Thank you for using NinjaTrader.​

              Comment

              Latest Posts

              Collapse

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