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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      154 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      306 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      244 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      345 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      176 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X