Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SharpDX Ellipse Rendering and Radius

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

    SharpDX Ellipse Rendering and Radius

    Hello,

    I'm trying to Draw an Ellipse to the Chart with SharpDX(https://ninjatrader.com/fr/support/h...rawellipse.htm) but i does not understand how to use this documented fonction.

    Can anyone help me ?

    Thanks
    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    #2
    Does this help:

    Code:
    myEllipse    = new SharpDX.Direct2D1.Ellipse(myCentrePoint.ToVector2(), 50, 50);
    RenderTarget.DrawEllipse(myEllipse, brush, strokeWidth;
    Sorry, I'm no expert.

    Comment


      #3
      Thanks for your answer,

      How do you build your variable myCentrePoint ?
      johnok
      NinjaTrader Ecosystem Vendor - Trade With Me

      Comment


        #4
        From:
        Code:
        Point myCentrePoint = StartAnchor.GetPoint(chartControl, chartPanel, chartScale);
        I modified:
        Code:
        NinjaTrader.NinjaScript.DrawingTools.FibonacciLevels
        This part of the code is in OnRender.

        Unfortunately, I don't fully understand it, but I got what I needed - an ellipse.

        Comment


          #5
          Hello johnok,

          Thank you for your post.

          Please see the attached example script demonstrating how to use SharpDX to draw an ellipse using RenderTarget.DrawEllipse.

          In the example script, we get the ChartPanel coordinates for our startpoint and endpoint. The startpoint and endpoint are used to calculate the center point that will be used for the ellipse. Once we have our center point we create a SharpDX Brush to use for our ellipse. After a SharpDX Brush is made, we calculate the X and Y radius which will be used to create our ellipse. Now that we have our center, x radius, and y radius, we create the ellipse. After the ellipse is created, we call RenderTarget.DrawEllipse() to draw the ellipse on the chart.

          See the help guide documentation below for more information. Also, see the SampleCustomRender indicator that comes default with NinjaTrader for more examples of using SharpDX. To view SampleCustomRender, you would open a New > NinjaScript Editor window, open the Indicators folder, and select the SampleCustomRender file.

          Using SharpDX for Custom Rendering — https://ninjatrader.com/support/help..._rendering.htm
          ChartPanel — https://ninjatrader.com/support/help...chartpanel.htm
          RenderTarget.DrawEllipse - https://ninjatrader.com/support/help...rawellipse.htm

          Let us know if we may assist further.
          Attached Files
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Thank everyone, i'm able to draw an Ellipse and i will try to understand everything !
            johnok
            NinjaTrader Ecosystem Vendor - Trade With Me

            Comment


              #7
              Hello Brandon,
              your example creates a second chart section. How can I avoid this?
              Is it possible to draw the center of an ellipse on a specific date of the abscissa and a few points below the low of the current bar?
              Kind regads
              Gerik

              Comment


                #8
                Hello Gerik,

                Thanks for your post.

                The IsOverlay property determines if the script is placed on the price panel or in a separate panel on the chart window.

                You could change the IsOverlay property to true in State.SetDefaults to have the ellipse object rendered on the price panel instead of in a separate panel.

                See this help guide page for more information about IsOverlay: https://ninjatrader.com/support/help.../isoverlay.htm

                You could consider using GetXByTime() to get the x coordinate of a specific date and time.

                GetYByValue() could be used to get a y-pixel coordinate on the chart determined by a series value, such as the Low of a bar (Bars.GetLow()), represented on the chart scale.

                You could try using these methods to calculate a center point for your ellipse.

                The tips of this help guide page might help you to calculate where the middle of the ellipse needs to be and where you want it in relation to the x and y axis:


                See the help guide documentation below for more information.

                How to Custom Render an Ellipse with SharpDX: https://ninjatrader.com/support/help...LinesAndShapes
                GetXByTime(): https://ninjatrader.com/support/help...getxbytime.htm
                GetYByValue(): https://ninjatrader.com/support/help...etybyvalue.htm
                Bars.GetLow(): https://ninjatrader.com/support/help...nt8/getlow.htm

                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                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