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

Drawing objects have auto-scale,is there a built in method for onRender() auto-scale?

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

    Drawing objects have auto-scale,is there a built in method for onRender() auto-scale?

    I look through the docs best I could, but could not find such an option.

    But that is the question, is there a way to auto-scale items drawn within onRender(), or would I have to write my own function to accomplish this?

    Figured I'd ask before I reinvent the wheel.

    #2
    Hello forrestang,

    OnRender does not account for scaling automatically so that is something you would have to add. When drawing you will be providing x/y and width/height generally so those values will need to be calculated by you if they need scaled. The drawing tools are good examples of how to do some of your own calculations based on the chart dynamics. You can explore the code for the existing tools to see how they are scaled in their OnRender.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I got the Y-scale auto-scale working a while back using OnCalculateMinMax().

      Just out of curiosity, is there a way to control right-edged auto-scaling, without manipulating margins via code? I can't think of a better term.

      I.e., imagine you drew a vertical line 30 bars to the right most bar(in onRender). That line would likely not be visible(depending on how one's margins were set).

      Is there a way to x-scale, autoscale?
      Last edited by forrestang; 03-04-2021, 08:42 AM.

      Comment


        #4
        Hello forrestang,

        Thank you for the reply.

        There is not a way to autoscale the x axis. The margins would likely be the best way to handle the situation you described if the line is a fixed length into the future. You would otherwise likely be looking at using custom keyboard events to manually scroll the chart when you draw your object as one possible solution. There is not an api to move the x axis or navigate the chart currently so using the existing keyboard commands is generally the suggested way.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello forrestang,

          Thank you for the reply.

          There is not a way to autoscale the x axis. The margins would likely be the best way to handle the situation you described if the line is a fixed length into the future. You would otherwise likely be looking at using custom keyboard events to manually scroll the chart when you draw your object as one possible solution. There is not an api to move the x axis or navigate the chart currently so using the existing keyboard commands is generally the suggested way.

          I look forward to being of further assistance.
          Thanks NT Jesse. Can you think of where a simple example of using a keyboard event exists?

          Comment


            #6
            Hello forrestang,

            Thank you for the reply.

            There is a sample in the rollover indications indicator in the following link:
            Shows a button on the chart to roll the expiry to the next available contract month. Option to hide button until a number of days before or on roll date. Another option to confirm by opening the instrument overlay selector or automatically rollover without confirmation. (Update June 27th, 2019 – Added an option to show […]



            I look forward to being of further assistance.


            The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
            JesseNinjaTrader Customer Service

            Comment


              #7
              If you can't think of where one is, don't' worry about it.

              But do you know where an example of how to implement a left-click and drag operation may be, with the minimum amount of code necessary to accomplish this may be? I.e., looking for an example of how to programmatically drag the chart left or right?

              I would imagine this could either be accomplished with either a left-click and drag... OR... a left or right arrow key operation?

              Comment


                #8
                Hello forrestang,

                I provided a sample in post #6, you need to follow the link I added in that post to get to that sample.

                Using keyboard events is not something NinjaScript has, you can use WPF keyboard event handling like that indicator shows. The sample demonstrates locating a control, using focus to make sure the control is in focus and then sending keys to that control.

                Left click or mouse events would not as easily be used, the chart has many existing mouse event handlers which you could break by trying to implement new actions with the mouse. If you want to experiment with that you could research how to handle WPF mouse events and then target a specific control like the ChartControl. The PreviewMouse events could be used to handle existing events as they occur.


                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by CortexZenUSA, Today, 12:53 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by usazencortex, Today, 12:43 AM
                0 responses
                5 views
                0 likes
                Last Post usazencortex  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,266 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                13 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X