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 burtoninlondon, Today, 12:38 AM
      0 responses
      5 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      12 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      13 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,982 views
      3 likes
      Last Post jhudas88  
      Working...
      X