Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fixed Scale Button

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

    Fixed Scale Button

    Dear NinjaTrader Support Team,

    i am working on an indicator which should be able to switch between Fixed and Automatic ChartScale.
    This works fine by setting the following ChartScale Properties:

    ChartScale.Properties.YAxisRangeType = YAxisRangeType.Fixed || YAxisRangeType.Automatic
    ChartScale.Properties.FixedScaleMax = <double>
    ChartScale.Properties.FixedScaleMin = <double>

    The only problem i have, is that the Fixed Scale "F" Button does not respond to programmatically changes to these ChartScale Properties.
    I've used Inspect to see if this button has an automationId, but the first parent element with an automationId is the actual TabControl (ChartWindowTabControl).
    From there i would need to find my way down to the actual "F" button and try to set the visibility.

    I know that this is pretty much outside of any supported Scope but could you please give me a hint what i would need to do to toggle the "F" button?
    The only thing that worked until now is to use SendKeys.SendWait("{F5}") which reloads the whole chart and isn't an actual option for me.

    Is there anything else i could try to trigger the method which toggles the button?
    I wouldn't ask if this wasn't a pretty important feature in order for the indicator to be useful.

    Thank you very much and Best Regards,
    Mike

    #2
    Hello Mike,

    This would not be supported by NinjaTrader. The FixedScale is read-only.

    "Warning: These are UI properties which are designed to be set by a user. Attempting to modify these values through a custom script is NOT guaranteed to take effect. "


    A workaround is to remove all chart objects from the auto scaling, and allow one indicator to set the min/max in OnCalculateMinMax().
    I have a summary indicator that collects information from my other indicators and outputs a stack of bubbles that show bullish, bearish or neutral. I need to &quot;fix&quot; the y-axis. For example, If I have 10 stacked bubbles, plotted at values of 1-10, then I want the y-axis to start at -1 and end at 11 so that the top and


    I am not aware of any way to toggle the "F" button in code.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hey NinjaTrader_ChelseaB,

      thank you for the clarification.
      As for the workaround, are you talking about these ChartObjects?


      So i had to loop over all of them and set the AutoScale to false in order to make this work or what would be the actual effect of the workaround?

      Thank you,
      Mike

      Comment


        #4
        Hello Mike,

        By all chart objects, I am referring to manually disabling the Auto Scale for all data series in the Data Series window, all Indicators in the Indicators window (except for the one indicator that will be controlling the max/min), all drawing objects in the Drawing Objects window.

        By leaving one indicator with Auto Scale on, this indicator will have control of the scale by setting the max/min.

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello NinjaTrader_ChelseaB,

          thank you for your answer.
          As this is an indicator which is used by many people, i guess it would kind of be a problem to just change all these chart object properties.
          I thought that there is an event or method which toggles the "Fixed Scale" button, as its visibility is set when a user fires the mouse drag event on the chart scale and also when a user changes the YAxisRangeType in the properties window. I had some hope that i could somehow trigger this visibility check with a propertiesChanged event or use a hook by changing some properties who would then trigger the visibility check.

          The functionality of the indicator works as expected but it currently breaks the UI because of the Fixed Scale button.

          Thank you,
          Mike

          Comment


            #6
            Code:
            NTWindow ntWindow = (NTWindow)Window.GetWindow(ChartControl.Parent);
            System.Windows.Controls.TabControl tabControl = ntWindow.FindFirst("ChartWindowTabControl") as System.Windows.Controls.TabControl;
            
            foreach(System.Windows.Controls.TabItem tabItem in tabControl.Items)
            {
                ChartControl tabChartControl = (tabItem.Content as ChartTab).ChartControl;
            
                if(tabItem.IsSelected)
                {
                    if(ScaleJustification == ScaleJustification.Left)
                    {
                        try
                        {
                            System.Windows.Controls.Button fixedScaleButton = tabChartControl.Children.OfType<System.Windows.Controls.Button>().Where(b => b.Content.ToString() == "F").First();
            
                            fixedScaleButton.Visibility = (ChartScale.Properties.YAxisRangeType == YAxisRangeType.Fixed) ? Visibility.Visible : Visibility.Hidden;
                        }
                        catch(Exception e) {}
                    }
                    if(ScaleJustification == ScaleJustification.Right)
                    {
                        try
                        {
                            System.Windows.Controls.Button fixedScaleButton = tabChartControl.Children.OfType<System.Windows.Controls.Button>().Where(b => b.Content.ToString() == "F").Last();
            
                            fixedScaleButton.Visibility = (ChartScale.Properties.YAxisRangeType == YAxisRangeType.Fixed) ? Visibility.Visible : Visibility.Hidden;
                        }
                        catch(Exception e) {}
                    }
                }
            }​
            Last edited by mk77ch; 11-03-2022, 04:50 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            587 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            341 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
            555 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X