Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw a horizontal line instead of rectangle

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

    Draw a horizontal line instead of rectangle

    Good morning all,

    How can I change the following code to draw a horizontal line instead of a rectangle? thanks for your help

    // unfinished auction

    if(showUnfinished)

    {

    if(rd.Key == currBarItem.l.Keys.Min())

    {

    if(rd.Value.av > 0.0 && rd.Value.bv > 0.0)

    {

    askBrush.Opacity = 0.05f;

    RenderTarget.DrawRectangle(rect, askBrush);

    rect.Width = rect.Width - 1;

    rect.Height = rect.Height - 1;

    RenderTarget.FillRectangle(rect, askBrush);

    rect.Width = rect.Width + 1;

    rect.Height = rect.Height + 1;

    vec1.X = rect.X;

    vec1.Y = y1 - 1f;

    vec2.X = rect.X;

    vec2.Y = y2;

    askBrush.Opacity = 0.44f;

    RenderTarget.DrawLine(vec1, vec2, askBrush, 1);

    vec1.X = rect.X + cellWidth;

    vec1.Y = y1 - 1f;

    vec2.X = rect.X + cellWidth;

    vec2.Y = y2;

    RenderTarget.DrawLine(vec1, vec2, askBrush, 1);



    #2
    Hello futuros,

    Thank you for your post.

    I note that we have an identical request for the above that was emailed directly to our platform support team and has already been answered by one of our other technicians. If you have not received this email, please check your Spam folder and ensure you have added platformsupport [at] ninjatrader[dot] com to your address book so you may receive our emails.

    Making a forum post that is related or identical to a previous inquiry you have emailed about before, may cause that technician to start at the beginning of reviewing your inquiry, tying up resources with our platform support and delaying our ability to respond to all customers in a timely manner.

    I'm including my colleague Brandon's reply to you below:

    It seems like rect.X is your x position. What you could do is add some pixels to this to move the line to the right. The code to accomplish this would look something like this.

    vec1.X = rect.X + 30;

    Here are some help guide links about Draw.Rectangle and Draw.Line.

    Draw.Rectangle — https://ninjatrader.com/support/help..._rectangle.htm

    Draw.Line — https://ninjatrader.com/support/help.../draw_line.htm

    Please let us know if we may assist further.

    Comment


      #3
      Hi Kate,

      Yes, I did receive his answer but this: vec1.X = rect.X + 30; didn't draw a line, that's why I posted here the same question hoping that someone else (one of the hundreds of traders that read this forum) can give me a better answer.

      Thanks

      Comment


        #4
        Hello futuros,

        Thank you for your reply.

        I believe he is saying to use rect.X as the start point of the line and use rect.X + a number of pixels as the end point and then use RenderTarget.DrawLine to draw the line you want instead of RenderTarget.DrawRectangle, then omitting the following lines:

        Code:
        rect.Width = rect.Width - 1;
        
        rect.Height = rect.Height - 1;
        
        RenderTarget.FillRectangle(rect, askBrush);
        
        rect.Width = rect.Width + 1;
        
        rect.Height = rect.Height + 1;
        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Hello futuros,
          Let me not get into your code & simply say if you want to draw a horizontal line instead of rectangle, I save as the original rectangle & modify its height as a constant 0. It works perfectly fine for me.

          Comment


            #6
            Originally posted by s.kinra View Post
            Hello futuros,
            Let me not get into your code & simply say if you want to draw a horizontal line instead of rectangle, I save as the original rectangle & modify its height as a constant 0. It works perfectly fine for me.
            Thank you s.kinra...

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 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
            554 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