Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set line thickness in Draw.Line?

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

    How to set line thickness in Draw.Line?

    Hi everyone,

    I'm trying to draw a horizontal line using Draw.Line, but I can't find a way to change the line thickness. My current code looks like this:


    Draw.Line(this, CurrentBar + ".VsalineDown", 1, High[1] - 1, -20, High[1] - 1, Brushes.Yellow); all it's ok

    But when I try different posibilities

    Draw.Line(this, CurrentBar + ".VsalineDown", 1, High[1] - 1, -20, High[1] - 1, Brushes.Yellow, , DashStyleHelper.Solid, ....


    I would like to make the line thicker, but I don’t see an option to set the width.

    Is there a way to increase the thickness of a Draw.Line?

    If not, what is the best alternative?

    Thanks in advance!

    #2
    Hello fersanmito,

    Welcome to the NinjaTrader forums!

    Use the overload signature with the width parameter.

    Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, DashStyleHelper dashStyle, int width)
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


    I am also including a link to a support article with helpful resources on getting started with NinjaScript and C#.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi thanks for your answer but the sample is not working,

      // Draws a dotted lime green line from 10 bars back to the current bar
      // with a width of 2 pixels
      Draw.Line(this, "tag1", false, 10, 1000, 0, 1001, Brushes.LimeGreen, DashStyleHelper.Dot, 2);

      https://developer.ninjatrader.com/docs/desktop/draw_line

      Draw.Line(this, CurrentBar + ".VsalineUp", 0, Open[0], power*-1, Open[0], Brushes.DarkGreen, DashStyleHelper.Solid, 2);

      Attached Files

      Comment


        #4
        Hello fersanmito,

        You have excluded the isAutoScale parameter. You must provide all parameters for this overload signature and not leave any out.

        The endBarsAgo value you are supplying 'power*-1' might not be an integer and may be double. The value you choose here must be an int (whole number with no decimal) and must be equal to or greater than 0 and less than CurrentBar.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi, whether positive or negative, the result is the same. The issue is not about direction, but about the line thickness in Draw.Line.
          Attached Files

          Comment


            #6
            Hello fersanmito,

            Supply all of the required parameters to use this overload signature.

            You will have to add the isAutoScale parameter as directed.

            Use a higher value for the width property for a line with a higher thickness.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks so much , now is perfect !!

              if ((CrossAbove(EMA1, EMA2, 1))

              && (CandlestickPattern1[0] == 0))

              {
              Draw.Line(this, $"EstrategiaXma_Line_{arrowCounter}", false, 1, Low[1] - 1, -20, Low[1] - 1, Brushes.Green, DashStyleHelper.DashDot, 3); // Estilo de línea (puede ser sólido, punteado, etc.)
              arrowCounter++;

              }

              // Set 2
              if ((CrossBelow(EMA1, EMA2, 1))
              && (CandlestickPattern2[0] == 0))
              {
              Draw.Line(this, $"EstrategiaXma_Line_{arrowCounter}", false, 1, High[1] + 1, -20, High[1] + 1, Brushes.Red, DashStyleHelper.DashDot, 3);
              arrowCounter++;

              }

              }​

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              556 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              545 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X