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

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 Brevo, Today, 01:45 AM
      0 responses
      6 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      4 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      242 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      384 views
      1 like
      Last Post Gavini
      by Gavini
       
      Started by oviejo, Today, 12:28 AM
      0 responses
      6 views
      0 likes
      Last Post oviejo
      by oviejo
       
      Working...
      X