Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRectangle() bug or what am I missing?

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

    DrawRectangle() bug or what am I missing?

    DrawRectangle("tag1", 10, Low[10], 0, High[5], Color.Blue);

    I'm doing something wrong... put that code in onBarUpdate() and it does not draw the rectangle on the right of the screen, I mean there chart plots data much past the right edge of the right side of the rectangle.

    How can I draw a rectangle that goes right to most recent bar?

    #2
    It depends on which bar you started drawing on. If you drew the rectangle and the market continued to add points the rectangle won't be on the edge.

    The syntax is this:
    DrawRectangle(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I am drawing it in onBarupdate, so should be at edge always.

      Is it possible that it is not at the edge because markets are closed right now?

      Or should it be at the edge even when not connect to a datafeed?

      my example displayed is just trying to modify help file example so that it draws the rectangle at the edge. I want to achieve an "right edge aligned" rectangle.

      Comment


        #4
        It depends how you are doing it. Please post the code snippet.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          very strange... my indicator with the problem has way too much code to paste here, however when I try to put the same code that works in that indicator into a new indicator, it doesn't even draw a rectangle?!?

          here is code from MyCustomIndicator which I used for testing... it uses same initialize() true/false settings as my real indicator, and the same drawrectangle line as in my real indicator. It is just that this MyCustomIndicator does nothing... don't know why. I could've sworn that yesterday I made a similar test indicator and it did work... so did a test strategy. The only problem was that '0' is not the last bar... anyhow today it doesn't even draw a rectangle. But my real indicator still draws the rectangle....

          anyhow if this drawrectangle is put into my real indicator then it will draw the rectangle.. it is just that '0' is not the last bar of the chart... it is more like the middle of the chart window. There are many bars after that... I am not connected right now to any server.

          Code:
                  /// <summary>
                  /// This method is used to configure the indicator and is called once before any bar data is loaded.
                  /// </summary>
                  protected override void Initialize()
                  {
                      BarsRequired = 200;
                      
                      AutoScale           = false;
                      DisplayInDataBox    = false;
                      CalculateOnBarClose    = true;
                      PaintPriceMarkers    = false;
                      Overlay                = true;
                  }
          
                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                      DrawRectangle("abcrect", false, 10, Low[100], 0, High[0], Color.Black, Color.Black, 5);
                  }
          Last edited by NinjaCustomer; 05-18-2008, 01:22 PM.

          Comment


            #6
            note, I just tested drawregion using sample bollingband example from help file... it exhibits same behaviour... there are many bars drawn after the '0' bar, which is around the middle of the chart

            Comment


              #7
              The reason is because you are calling an index of 100 without first doing the CurrentBar check.

              Josh P.NinjaTrader Customer Service

              Comment


                #8
                ok, thanks that gave me some clues as to what was going on... my indicator had a lot of code so was tough to see everything also. So solved all my problems...

                just kinda confused why I need to do a bars checked in on bar update if barsrequired was 200, and I was only doing the last [100]... but doesn't matter really...

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                571 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                330 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
                548 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                549 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X