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

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
          Brandon H.NinjaTrader Customer Service

          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

                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by habeebft, Today, 07:27 AM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_ChristopherS  
                Started by AveryFlynn, Today, 04:57 AM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by Max238, Today, 01:28 AM
                4 responses
                37 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by r68cervera, Today, 05:29 AM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by geddyisodin, Today, 05:20 AM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X