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() 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 aussugardefender, Today, 01:07 AM
                0 responses
                1 view
                0 likes
                Last Post aussugardefender  
                Started by pvincent, 06-23-2022, 12:53 PM
                14 responses
                238 views
                0 likes
                Last Post Nyman
                by Nyman
                 
                Started by TraderG23, 12-08-2023, 07:56 AM
                9 responses
                383 views
                1 like
                Last Post Gavini
                by Gavini
                 
                Started by oviejo, Today, 12:28 AM
                0 responses
                1 view
                0 likes
                Last Post oviejo
                by oviejo
                 
                Started by pechtri, 06-22-2023, 02:31 AM
                10 responses
                125 views
                0 likes
                Last Post Leeroy_Jenkins  
                Working...
                X