Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The Arc drawing tool

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

    The Arc drawing tool

    Hello,

    I'm trying to understand how the "arc" is being calculated. I can make sense of something like the "fibonacci circle", I see how this depends on your screen resolution and/or scaling of the chart, hence when you change the scale of your chart, the circles change...

    However, with the "arc", the scale of the chart does not affect it, so I don't understand how it decides to draw the arc, given that you only provide a start and endpoint. I assume the start and endpoint represent a cord of some circle, but there are an infinite number of circles that could be drawn with that cord somewhere on there, so how does ninja decide which circle to use? Are there some assumed parameters built into this? I've looked at the code for this, but since I am not a coder, it's not helping me visualize what's going on here...

    Any hints much appreciated!

    #2
    Hello ra1den,

    Thank you for the post.

    I wanted to gather more details on the use case here, I tried placing an Arc on the chart and then scaling it but I see the arc being affected. Are you saying that when you scale the chart by either compressing/decompressing the X or Y scales, you do not see the object being resized at all? Changing the X scale should result in the tool becoming more or less wide with the bars, and Y would be more or less tall. Can you provide more detail on the use case here such as if this was manually or script drawn or any other useful details you can note?

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello, thanks for your reply. The arc does indeed appear to change visually as you scale the chart, but the line is actually not moving (which you can see by selecting a reference point on the chart). This is different than the fibonacci circle, where the lines actually move as you rescale it. It is the regular arc tool I am using, no scripts...I made a quick 1 min video to show this.



      So I am just trying to understand how the arc is being calculated based off of only a start and endpoint, as there could be any number of circles with that same cord (I assume the line represents a cord through a circle) through it, but Ninja chooses one in particular somehow, and scale is not being taken into consideration.

      Thanks so much!

      Comment


        #4
        Hello ra1den.

        Thank you for providing the video.

        I reviewed the video and your questions however I am still unclear on what your overall question is here.

        In your video, you closed with the question that you are unsure what inputs are used to draw the arc size, are you questioning the circular portion of the arc and how that circle's size is calculated? I am not certain how this specifically relates to the Fibonacci circle aside from the scaling differences shown in the video. These are two separate tools which use two different types of line rendering so I would expect differences in how they render and scale. In addition to that, there are also different math calculations happening in each tool so I am unsure if this would be something that could be directly compared.

        The arc tool is specifically drawing an arc based on two data points which each consist of X and Y values along with the other arc properties. It is using Path geometry to accomplish that which is essentially the following syntax:

        Code:
        SharpDX.Direct2D1.ArcSegment arcSegment = new SharpDX.Direct2D1.ArcSegment
                    {
                        ArcSize            = SharpDX.Direct2D1.ArcSize.Small,
                        Point            = new SharpDX.Vector2((float) endPoint.X, (float) endPoint.Y),
                        SweepDirection    = SharpDX.Direct2D1.SweepDirection.CounterClockwise,
                        Size            = new SharpDX.Size2F(width, height)
                    };
        arcGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
        SharpDX.Direct2D1.GeometrySink geometrySink = arcGeometry.Open();
        geometrySink.BeginFigure(new SharpDX.Vector2((float)startPoint.X, (float)startPoint.Y), SharpDX.Direct2D1.FigureBegin.Filled);
        geometrySink.AddArc(arcSegment);
        geometrySink.EndFigure(SharpDX.Direct2D1.FigureEnd.Open);
        geometrySink.Close();
        The Fibonacci tool is using the levels collection it has to generate circles which is drawn using:
        Code:
        RenderTarget.DrawEllipse(ellipse, priceLevel.Stroke.BrushDX, priceLevel.Stroke.Width, priceLevel.Stroke.StrokeStyle);

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

        Comment


          #5
          Hi Jesse, thanks much for your reply. My question is simply this: How can Ninja draw the arc of a circle with only 2 points selected by the user? A rule of geometry is that 2 points are not enough to define a unique circle, we need at least 3 points (or some other assumption). Yet somehow Ninja is drawing an Arc based off of only two points...so I'm wondering what hidden assumptions the code is making to allow for this. I took a look at the code, but as I'm not a coder, I can't understand what it's saying. Was just hoping for a basic explanation of how a circle (or the arc of a circle) can be defined by 2 points, no need for anything too in depth, but just an idea of what is going on here...

          The only reason I brought up the Fibonacci Circle is because I noted that it is making assumptions based off of chart scale, hence there was no mystery about how it could define a circle with only 2 points given by the user, as it is taking other information (chart scale) into account...but since the Arc tool is NOT taking scale into consideration, the arc tool is making a different assumption. I'm trying to find out what this assumption is.

          Hope this is clear, thanks!

          Comment


            #6
            Hello ra1den,

            Thank you for your reply.

            How can Ninja draw the arc of a circle with only 2 points selected by the user?
            To answer your question directly, the arc tool's UpdateArcGeometry method is needed which uses SharpDX's arc calculation methods and Path Geometry to do this. Two points is not all that is required as you also noted, this is just not visible from the user interface and is instead a programming concept with the rendering library being used. You are also correct, the Fibonacci tools do take some other variables into account.

            To put more detail to this, NinaTrader is using the SharpDX library for rendering which has some native Arc creation methods, this all comes from DirectX in windows. An ArcSegment is created with the size and general arc properties along with an end point. This is used to calculate the arc from the start point using Path Geometry.

            The Fibonacci tool does work similar in the sense that it also uses X/Y points and renders however it does do some other math before actually using the X/Y values in its drawing so we can see the exaggerated scaling effect in comparison to the arc. The arc is adjusting with the scale in the sense that it gets wider or taller etc when scaling but does not change exponentially like the Fibonacci seems to so it more or less just sticks to the bars when rendered.

            The sticking to the bars when rendered is what you usually get when rendering, the Fibonacci circles has a specific property which allows you to control this to be more like the arc which is the IsTimePriceDividedSeparately property. This is false by default, setting this to true you can see the circles compress and decompress with the bars instead of increasing/decreasing in size. This is the main part of the difference you had shown in the video between the tools, mainly the Fibonacci tool is doing some math which generates larger or smaller circles depending on the range.




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

            Comment


              #7
              Hi Jesse, thanks for this detailed response. I'll look into SharpDX further.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              14 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              229 views
              0 likes
              Last Post TradingLoss  
              Started by agclub, 04-21-2024, 08:57 PM
              3 responses
              17 views
              0 likes
              Last Post TradingLoss  
              Started by TradingLoss, 04-21-2024, 04:32 PM
              4 responses
              43 views
              2 likes
              Last Post TradingLoss  
              Started by cre8able, 04-17-2024, 04:16 PM
              6 responses
              56 views
              0 likes
              Last Post cre8able  
              Working...
              X