Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Disabling Indicator Plot Auto-Scaling

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

    Disabling Indicator Plot Auto-Scaling

    I wasted a ridiculous amount of time merely trying to prevent an indicator plot from auto-scaling. I expected this to work, but it didn't:
    Code:
            if (State == State.SetDefaults) {
                Name = "myIndicator";
                IsOverlay = false;
                IsAutoScale = false;
                MaxValue = 100;
                MinValue = 0;
            }
    Eventually I saw OnCalculateMinMax() mentioned somewhere and tried this, which works:
    Code:
            public override void OnCalculateMinMax() {
                MaxValue = 100;
                MinValue = 0;
            }
    The OnCalculateMinMax() help page says to "set IsAutoScale to true in State.SetDefaults to ensure CalculateMinMix() is called." However, OnCalculateMinMax() is always called regardless of the IsAutoScale setting, and without the code above, auto-scaling always occurs regardless of that setting.

    #2
    If the purpose of IsAutoScale is to able set whether or not to auto-scale plots, this is an NT bug, because that setting has no effect on plot auto-scaling. If that isn't the purpose, what is the purpose and where is it documented?

    If the OnCalculateMinMax() code shown above is the only way to defeat auto-scaling, that should be documented in the help.

    Comment


      #3
      Hello caveat_lector,

      Thank you for your post.

      IsAutoScale does indeed control whether plots are autoscaled within the window. You can test this with the Prior Day OHLC indicator very easily if you add it to the chart and switch between Auto Scale settings in the parameters.

      It sounds like something else may have been the case. Would you be able to provide an example indicator that you can reproduce this behavior with so I may test on my end?

      Thanks in advance; I look forward to assisting you further.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        I found this problem while developing an unusual indicator that I don't won't to disclose, but you can easily see the problem as follows. Save a copy of one of the standard indicators supplied with NT that plots in a lower panel, such as the RSI indicator. Add these assignments to its State.SetDefaults conditional section:
        Code:
                    IsAutoScale = false;
                    MaxValue = 100;
                    MinValue = 0;
        Then recompile, add both that indicator and the unmodified indicator to a price chart, and you will see that even though the modified indicator is set to not auto-scale it still auto-scales exactly the same the original indicator.

        Now add this seemingly undocumented code to the modified indicator:
        Code:
                public override void OnCalculateMinMax() {
                    MaxValue = 100;
                    MinValue = 0;
                }
        Recompile and you will see that the Y-axis plot range is now 0 to 100 and the plot no longer auto-scales.
        Last edited by caveat_lector; 06-01-2020, 12:48 PM.

        Comment


          #5
          Hello caveat_lector,

          Thank you for your reply.

          In testing this I did find unusual behavior occurring with the RSI with that particular code added. I've sent it over to our development team and am waiting to hear back. I'm currently tracking this under the number TS-2312 and will let you know what I hear back from them.

          Thanks in advance; I look forward to assisting you further.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Has there been any feedback from the development team about this?

            Comment


              #7
              Hello caveat_lector,

              Thank you for your reply.

              At the current time I have yet to receive news from the development team. As soon as I do, I will let you know!

              Thanks in advance; I look forward to assisting you further.
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Hello caveat_lector,

                Thank you for your patience.

                I've finally heard back from our development team on this. IsAutoScale = false is only effective when there are other chart objects on that scale with AutoScale. In other words - the scale MUST hold at least one chart object which is scaled. If none exist, then first object will be scaled anyway.

                It appears our documentation was lacking for this and it should be updated soon.

                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Rather than changing the documentation, wouldn't be better to make IsAutoScale = false effective regardless of whether there are other chart objects that AutoScale?

                  Comment


                    #10
                    Hello caveat_lector,

                    Thank you for your reply.

                    I have created a feature request on your behalf to have IsAutoScale = false effective regardless whether there are other chart objects that do autoscale. This request is being tracked under the number SFT-4934.

                    As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                    Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

                    Please let us know if we may be of further assistance to you.
                    Kate W.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by gravdigaz6, Today, 11:40 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post gravdigaz6  
                    Started by MarianApalaghiei, Today, 10:49 PM
                    3 responses
                    9 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by XXtrader, Today, 11:30 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post XXtrader  
                    Started by love2code2trade, Yesterday, 01:45 PM
                    4 responses
                    28 views
                    0 likes
                    Last Post love2code2trade  
                    Started by funk10101, Today, 09:43 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post funk10101  
                    Working...
                    X