Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coding A Dashed Horizontal Line

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

    Coding A Dashed Horizontal Line

    Hi there,

    I've been struggling to add specifications to a horizontal line (Mid-Line) in my custom indicator.

    I'd like to add a 'Dash' dashstyle.

    But so far it seems that horizontal lines are limited.

    Here is the code for my horizontal line:

    AddLine(Brushes.White, 50, "Mid-Line");
    Lines[1].Width = 2F;

    Would it be better to use a Draw.HorizontalLine code for integrating dashstyles?

    I've been able to integrate dashstyles into my plots before, but struggling to integrate it with horizontal lines.

    Any help would be much appreciated

    #2
    Hello RoswellTrader,

    Thank you for your post.

    A Stroke object would allow you to use the Dash DashStyle in a call of AddLine(). I also see you are changing the width of the line; the width can be defined in the Stroke as well. You could do this with the following syntax:
    AddLine(Stroke stroke, double value, string name)

    Here is more information about the stroke class:


    The following Stroke syntax would let you select the brush, DashStyle, and width:
    Stroke(Brush brush, DashStyle dashStyleHelper, float width)

    Using your snippets, the call of AddLine() could look like the following:
    Code:
    AddLine(new Stroke(Brushes.White, DashStyleHelper.Dash, 4), 50, "Mid-Line");
    Please let us know if we may be of further assistance.

    Comment


      #3
      Hi Emily, thanks so much for your help

      I integrated the piece of code you sent, and it's working perfectly!

      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