Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRectangle

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

    DrawRectangle

    When using DrawRectangle how can I set the OutLine width and line style. Mine defaults to drawing the outline with a Dotted pen. Would like to make it Solid. Would also like to control the width of the draw.

    I have tried but failed using:

    Pen OutLinePen = new Pen(Brushes.Black);
    OutLinePen.DashStyle = DashStyle.Solid;

    DrawRectangle(string tag, bool autoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, OutLinePen, Color areaColor, int areaOpacity)

    OutLinePen.Dispose();

    #2
    Originally posted by TAJTrades View Post
    When using DrawRectangle how can I set the OutLine width and line style. Mine defaults to drawing the outline with a Dotted pen. Would like to make it Solid. Would also like to control the width of the draw.

    I have tried but failed using:

    Pen OutLinePen = new Pen(Brushes.Black);
    OutLinePen.DashStyle = DashStyle.Solid;

    DrawRectangle(string tag, bool autoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, OutLinePen, Color areaColor, int areaOpacity)

    OutLinePen.Dispose();
    Those do not look like correct parameters for the NT override of DrawRectangle. To do what you want, you are probably going to have to use the original C# DrawRectangle() function. e.g.,

    Code:
     
    public void DrawRectangleInt(PaintEventArgs e)
    {
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
    // Create location and size of rectangle.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 200;
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
    }
    You will have to calculate int x and int y using the NT functions:
    Code:
     
    int x = ChartControl.GetXByBarIdx(BarsArray[0], idx);
    int y = ChartControl.GetYByValue(this, val);
    The functions are spoken about in the NinjaScript Code Breaking changes document avaialble from the NT WebHelp site. http://www.ninjatrader.com/support/h...er_11_2010.pdf

    You can see some other examples in the CustomPlotSample indicator that ships with NT.

    Comment


      #3
      koganam,

      Was hoping that would not be the case. I already utilize that method for custom plots and other drawings. For some reason I thought that NT had an overload that would do this without going down the override Plot path.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      169 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      326 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      252 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      353 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      180 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X