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 rhyminkevin, Today, 04:58 PM
      4 responses
      52 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      7 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      14 views
      0 likes
      Last Post 00nevest  
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      50 views
      0 likes
      Last Post futtrader  
      Working...
      X