Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

chartscale property (fixed) via c# code

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

    chartscale property (fixed) via c# code

    Hello, is it possible to call the chartscale property (fixed) via c# code?

    Click image for larger version

Name:	Screenshot_1.jpg
Views:	342
Size:	14.0 KB
ID:	1183377

    currently I reset the fixed scalling with the following code:

    Code:
    _chartScale.Properties.YAxisRangeType = YAxisRangeType.Automatic;
    But I would just like to use the existing property on the chart and would have to address the property for that.
    Attached Files
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thanks for your post.

    I am not not exactly sure what you are trying to accomplish differently. We have the NinjaScript object's AutoScale property, and we have the Fixed/Automatic scaling property for the ChartScale. Changing the ChartScale Fixed/Automatic scaling programmatically would be how you demonstrate in your snippet.

    Setting a fixed scale programmatically would look like:

    Code:
    chartScale.Properties.FixedScaleMin = 0;
    chartScale.Properties.FixedScaleMax = 100;
    chartScale.Properties.YAxisRangeType = YAxisRangeType.Fixed;
    Could you elaborate on what you want to do differently if this does not answer your question?

    Comment


      #3
      Hi _Jim, thank you for your reply.
      In my script, the YAxisRangeType = YAxisRangeType.Fixed is set when I move the chart with the mouse button pressed. Then I currently have to switch back to YAxisRangeType = YAxisRangeType.Automatic via key because the button is not displayed in the chart. I should be able to activate the button when I move the chart.

      I made a short video: http://www.youtube.com/watch?v=rxsloJuCugM
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        Hello sidlercom80,

        Thanks for clarifying.

        This looks like it would be a limitation of how the Fixed/Automatic scaling button gets added to the chart, and since the ChartScale properties are intended to be modified by the user. While we can modify them programmatically, we do get this issue with the Fixed/Automatic button not appearing when doing so. (ChartScale Properties note that these are UI properties intended to be set by the user.)

        Since the script is overriding the scaling by writing its own fixed scale, you could consider adding your own button to disable the forced Fixed scaling and revert back to Automatic. This may not be ideal, but may be worth considering.

        Comment


          #5
          Hi _Jim, I almost thought so ;-) the button I have no problem. How do I get the button on the same place in the chartscale and not in the menu?

          it doesn't work that way;
          Code:
          ChartPanel.Scales.Add(btnFixScale);
          sidlercom80
          NinjaTrader Ecosystem Vendor - Sidi Trading

          Comment


            #6
            Hello sidlercom80,

            I would have gone with adding a small button to UserControlCollection. that would reside in the very upper right corner, and still outside of the "Scroll to last bar" arrow.

            Rendering is clipped to be within the ChartPanel and outside of the price scale, and UserControlCollection binds controls to be within the ChartPanel with the same rules. I don't have any suggestions to share to add anything to the price scale space on the chart.

            Comment


              #7
              Hi _Jim, is there also a property for querying the status from Fixed/Automatic scaling button, as with ChartControl.IsScrollArrowVisible?
              sidlercom80
              NinjaTrader Ecosystem Vendor - Sidi Trading

              Comment


                #8
                Hello sidlercom80,

                There wasn't anything I saw for that purpose. I also had a look with the Windows Inspect tool to see if there was an Automation ID that could be used to find the button and check its visibility, and there wouldn't be anything to use there.

                Adding your own "Return to AutoScale" button can be shown if (chartScale.Properties.YAxisRangeType == YAxisRangeType.Fixed) There may be cases where NinjaTrader's "Return to AutoScale" button appears when a user changes the property through the UI, and your script will also show its button. I don't think there would be a way around this scenario.

                Comment


                  #9
                  Thank you _Jim for your work! That would have been too easy ;-) I will keep trying.
                  sidlercom80
                  NinjaTrader Ecosystem Vendor - Sidi Trading

                  Comment


                    #10
                    Hi _Jim, I made my own "F" button and have one last question ;-) can the original symbol be switched off or overwritten so that it is no longer visible on the chart?
                    sidlercom80
                    NinjaTrader Ecosystem Vendor - Sidi Trading

                    Comment


                      #11
                      Hello sidlercom80,

                      What do you mean by "the original symbol?" If you are referring to NinjaTrader's "F" button, I do not have any suggestion for finding/hiding this button.

                      Comment


                        #12
                        Hi _Jim, yes, that's exactly what I meant. Too bad that there is no solution for this, but thank you for your help!
                        sidlercom80
                        NinjaTrader Ecosystem Vendor - Sidi Trading

                        Comment

                        Latest Posts

                        Collapse

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