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 cmoran13, 04-16-2026, 01:02 PM
      0 responses
      43 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      25 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      163 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      98 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      158 views
      2 likes
      Last Post CaptainJack  
      Working...
      X