Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Emily C.NinjaTrader Customer Service

    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 Option Whisperer, Today, 09:55 AM
      1 response
      11 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      1 view
      0 likes
      Last Post port119
      by port119
       
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      3 views
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      2 views
      0 likes
      Last Post 00nevest  
      Started by Jonafare, 12-06-2012, 03:48 PM
      5 responses
      3,986 views
      0 likes
      Last Post rene69851  
      Working...
      X