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 Balage0922, Today, 07:38 AM
      0 responses
      5 views
      0 likes
      Last Post Balage0922  
      Started by JoMoon2024, Today, 06:56 AM
      0 responses
      6 views
      0 likes
      Last Post JoMoon2024  
      Started by Haiasi, 04-25-2024, 06:53 PM
      2 responses
      19 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      6 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,786 views
      0 likes
      Last Post Leafcutter  
      Working...
      X