Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with first Drawing tool

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

    Need help with first Drawing tool

    I took Lines as a starting point and trimmed out all but the DrawLine stuff for Horizontal lines. Then renamed classes and other things to be specific to my class. I am stuck with OnRender. In it there is a line for the Horizontal line:

    RenderTarget.DrawLine(startAdj.ToVector2(), endAdj.ToVector2(), Stroke.BrushDX, Stroke.Width, Stroke.StrokeStyle);

    I would like it to draw my line, not DrawLine:

    RenderTarget.DrawMyLine( this, "TAG", startAdj.ToVector2(), Brushes.Cyan );
    ​​
    'SharpDX.Direct2D1.RenderTarget' does not contain a definition for 'DrawMyLine' and no extension method 'DrawMyLine' accepting a first argument of type 'SharpDX.Direct2D1.RenderTarget' could be found (are you missing a using directive or an assembly reference?)

    How do I fix this?​
    Attached Files

    #2
    Hello Johnny Tarr,

    Thank you for your post.

    RenderTarget.DrawLine() is a SharpDX method that draws a line between the specified points; this should not require you to change the method to DrawMyLine:


    I suspect you may be confusing the RenderTarget.DrawLine() method with the NinjaScript drawing overload methods like Draw.Line(). My colleague has created a script that isolates the Line drawing tool into a CustomLine drawing tools script. Please see the script here and review the CustomLine overloads that were created to draw this custom tool specifically:


    Another script that creates custom drawing tools and includes NS methods for drawing them is the ChartMarkersPlus script that is publicly available on our NinjaTrader Ecosystem website:That script creates the DrawPlus methods and you could review how it was achieved there.

    Please let me know if I can be 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.

    Comment


      #3
      Thanks. Having trouble seeing how that would help. I don't see where the line is draw and where I could do something different.

      What I want to do, for example, is draw something like a circle with an arrow at the point where the user clicks the chart.

      Comment


        #4
        Hello Johnny Tarr,

        Thank you for your reply.

        Were you able to resolve the initial error message you posted about? You mentioned, " I don't see where the line is draw" - are you referring to where it is being drawn in a script or where it is being drawn visually on a chart?

        For a list of the methods and properties specific to drawing tools scripts, please see the help guide section here:


        Drawing tools scripts use OnRender() for custom rendering of the objects. You mentioned you want to be able to draw a circle with an arrow at the point; you can learn more about SharpDX lines and shapes, along with other custom rendering information, on the following page:


        Trying to isolate a specific line from the Lines.cs drawing tools script is a great place to start and understand the structure of a drawing tools script. With each change that you make, you can compile to check for errors and try to draw on the chart and test the behavior. It is also helpful to check the Log tab of the Control Center for any error messages. If you are getting any error messages or unexpected behavior, please provide a detailed description so we may understand and better assist you.

        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team to follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one-on-one educational services.

        Please feel free to reach out with any additional questions or concerns.

        Comment


          #5
          That's helpful. It seems like the coordinates in RenderTarget.DrawLine(startAdj.ToVector2(), endAdj.ToVector2(),... are in pixels, not ticks. In Indicator scripts I would use "pt.Y += 20* TickSize" to adjust a Y coordinate up or down. What is the equivalent way to do that in a Drawing Tool?

          Comment


            #6
            Hello Johnny Tarr,

            Thank you for your reply.

            There are different methods that could be used to get X and Y coordinates:I suggest reviewing the existing drawing tools scripts within the platform to get an idea of how these methods are used to get x and y coordinates.

            Thank you for your time and patience.

            Comment


              #7
              I have the start and end points: startAdj and endAdj but when I add 20 to the Y, the line drawn is not 20 ticks higher, it looks like pixels higher. That's what I need to solve..

              Comment


                #8
                Hello Johnny Tarr,

                Thank you for your reply.

                As mentioned in the dropdown section "ShapDX Vectors and Charting Coordinates" on this page I linked previously, ChartScale and ChartControl properties return WPF units. These are not quite the same as device pixels because the WPF units could be drastically different depending on the DPI of a user's display. The following pages should be helpful to understand this more in-depth:Please let us know if we may be of further assistance.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                597 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                343 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
                556 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                555 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X