• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

adding indicator to price panel on left

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

    adding indicator to price panel on left

    Hello, i have custom tool which draws a box on the price panel area over a number of bars with a start and end point defined.

    This works great and consistently correctly gets the start bar and end bar.

    I have noticed in the indicator panels below if any indicator is added that has scale justification set to left ... even in a lower indicator panel .. it adjusts any subsequent box area i try to draw with my custom tool in the price panel.

    As long as the scale justification is set to right or overlay all is good.

    I now have added an indicator which i want shown on the price panel 1. So i set scale justification to left so obviously it scales for my purposes - as i already am using the overlay slot.

    Any ideas what is causing this - i noticed months ago and havent gotten around to reporting it but now it is becoming an issue now that i am using price panel.

    Its almost like it shifts the X anchor or X bar that was the selected start point and shifts it left a number of bars

    thanks

    #2
    Hello explorer101,

    I'm not quite understanding the issue.

    The anchor time is not matching the bar time under the anchor?

    The rendering in the object is rendering in the wrong location?

    Do you have prints and output to show the issue?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Chelsea wrote :

      The rendering in the object is rendering in the wrong location?

      Yes the rendering is starting a bit to the left ; if i expand the chart bars i can see it is not a case of # bars shift but an X pixel/points shift. So both the start X and end X have shifted left.

      So when i receive the coordinates in my custom tool from capturing the start point to rendering something has shifted. As i said if i dont have any indicator OR something on the chart that is set to scale justification to the left then all is perfect. So is there something in the drawing tool or capturing the screen point clicks that needs to be adjusted if there is scale left justification on the chart. It would seem like there is some internal thing going on here in ninja ?

      Is difficult to send screenshot at moment ;

      thanks
      Last edited by explorer101; 08-22-2018, 08:30 AM.

      Comment


        #4
        Hello explorer101,

        Setting the justification to the left causes the scale to appear and would cover any objects rendered in that area.. but I'm not seeing that the x or y values of the chart panel are changing.

        I've created a very simple script that renders an ellipse with a hard coded 50 for the x value (we're only focusing on the x) and half the high of the chart as the y (just to make it easy to see).

        Then I've made a video and i've used the corner of notepad to line up where the circle is being rendered before and after changing the scale justification. The circle doesn't move. In case you might be running into a DPI scaling issue I tested with text size at 125% and at 100%. Unable to reproduce in any senario.
        https://drive.google.com/file/d/1OgE...w?usp=drivesdk

        Are the calculated x and y values used for the object changing if you print these? Are you referencing bar data to get the x and y values?

        If you test the attached test script and follow the steps in the video are you getting different behavior? (You don't have you change your text size scaling)
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          thank you and will check this out and get back to you
          Last edited by explorer101; 08-23-2018, 02:21 PM.

          Comment


            #6
            In looking at the code enclosed and my own and exploring the help pages on ScaleJustification and the :

            property set in OnStateChange and checking the chartScale.Scalejustification == ScaleJustification.Right in the OnRender.

            My drawing tool does not currently specify the ScaleJustification.RIght in OnStateChange or filter in the OnRender.

            So i was wondering if this could be part of the issue.

            I went through the code where i get the coordinates for the mouse events :

            P2 = e.GetPosition(ChartPanel);

            P2.X = ChartingExtensions.ConvertToHorizontalPixels(P2.X, ChartControl.PresentationSource);
            P2.Y = ChartingExtensions.ConvertToVerticalPixels(P2.Y, ChartControl.PresentationSource);

            from the above i perform a calculation to get the selected bar based on the X ;

            So just a summary but question at this stage was do i need to specify the ScaleJustification in the above areas ie in OnStateChange and or OnRender for the drawing tool in question

            thanks
            Last edited by explorer101; 08-23-2018, 01:45 PM.

            Comment


              #7
              Hello explorer101,

              If ScaleJustification is not set, then the default value of ScaleJustification.Right will be used.
              You can set the ScaleJustification property in State.SetDefaults if you would like.
              https://ninjatrader.com/support/help...tification.htm

              The page I think you are referring to in the help guide is a comparison not an assignment. (Two equal signs used in a branching command (if statement) means 'does this equal this', one equal sign means 'make this equal this')
              https://ninjatrader.com/support/help..._positions.htm

              Setting or not setting the ScaleJustification is not the cause of this behavior.

              Likely the values you are calculating are changing.

              Also, below is a link to an example (ClickDrawExample_NT8) that draws on the chart where you have clicked the mouse.
              https://ninjatrader.com/support/foru...045#post513045
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thanks i just wanted to check and exclude the justification setting as a possibility and i didnt think it was - will check over the coordinates and check if value of X is changing in my code and look at the sample

                thanks for help

                Comment


                  #9
                  Hello, so after looking at your example ... i changed the following ...

                  P2 = e.GetPosition(ChartPanel);

                  P2.X = ChartingExtensions.ConvertToHorizontalPixels(P2.X, ChartControl.PresentationSource);
                  P2.Y = ChartingExtensions.ConvertToVerticalPixels(P2.Y, ChartControl.PresentationSource);

                  to

                  P2.X = ChartingExtensions.ConvertToHorizontalPixels(e.Get Position(ChartControl as IInputElement).X, ChartControl.PresentationSource);
                  P2.Y = ChartingExtensions.ConvertToVerticalPixels(e.GetPo sition(ChartControl as IInputElement).Y, ChartControl.PresentationSource);

                  main change being to use e.GetPosition(ChartControl as IInputElement).X & Y

                  and i also added e.handled = true before exit of the mouseLeftButtonDown event handler function.

                  So this seems to have resolved the issue and now have left justified indicator/line and the correct start and end points for drawing tool are drawn.

                  Would you expect this in the above changes?

                  thanks

                  Comment


                    #10
                    Hello explorer101,

                    Thank you for your follow up in the matter.

                    You have correctly utilized the 'ClickDrawExample' and it's MouseClicked actions to correct this on your end.

                    Please let me know if you have any questions.
                    Patrick H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello, i presume chelsea is unavailable - i just wondered if/how i was incorrectly accessing the e.GetPosition - as explained with chelsea the issue only shows if i have a scale justification left on the chart ; there are different ways in ninja to achieve the same effect ; i just so happened to use the same approach now as chelsea's example. Question was what was i doing 'wrong' to lead to the problems in rendering i was seeing

                      thanks

                      Comment


                        #12
                        Hello explorer101,

                        Chelsea is out of the office today.

                        ChartPanel would be used for the coordinates relative to the render-able area. This gets offset by the price scale. On the right, this would effect ChartPanel.W while a scale on the left would effect ChartPanel.X. Since these coordinates are relative to the render-able area, using ChartControl for the InputElement would be a good solution to get the coordinates you are looking for.

                        Please let us know if there is anything else we can do to help.
                        JimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by tonynt, Today, 02:21 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post tonynt
                        by tonynt
                         
                        Started by alstsion, Today, 12:55 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post alstsion  
                        Started by kandster, Yesterday, 11:49 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post kandster  
                        Started by priceisking, Yesterday, 05:33 PM
                        0 responses
                        26 views
                        0 likes
                        Last Post priceisking  
                        Started by vivekniwas, Yesterday, 02:15 PM
                        1 response
                        16 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Working...
                        X