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 and scrolling

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

    DrawRectangle and scrolling

    When I draw a rectangle in an indicator panel, and then scroll backward, I very soon run out of rectangle. F5 will cause it to be drawn where I am, but if I scroll back the same thing happens.

    My best guess is that the left-most rectangle data is not kept, and as I scroll left OnBarUpdate() is not called, so the rectangle does not get updated.

    How do I fix this?

    (I'm sure I have seen this answered before, but I cannot find that now that I need it.)

    One thing I can think of that might work is to override Plot(), draw the rectangle there, and then call base.Plot(). Or maybe in the other order.

    --EV

    #2
    ETFVoyageur,

    Yes, if you're trying to draw a rectangle in a fixed position on the chart, it's required to override the plot method.

    Our support for this is to point to the built in CustomPlotSample, but unfortunately we can't assist with the exact implementation. You may get some help searching these forums to see what others have done in this area.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      What I am trying to do is to shade the area between two horizontal lines.

      Does that require overriding Plot(), or is there a more mainstream way to go?

      If I do override Plot(), I presume that my idea to just draw the rectangle and have base.Plot() is the way to do?

      --EV

      Comment


        #4
        Have you tried DrawRegion() for this?


        Last edited by NinjaTrader_RyanM1; 01-19-2011, 12:30 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          No, I forgot all about that.

          I did not go that way in the first place because I need to create a DataSeries for both the top and bottom lines, which seemed heavier weight.

          Am I right that I do need to create those DataSeries, and cannot just use the Line objects as parameters to DrawRegion?

          --EV
          Last edited by ETFVoyageur; 01-19-2011, 12:53 PM.

          Comment


            #6
            Yes, that's correct. You will have to use a data series for at least one of the y values, but can use an overload that offers double as input for the other y value. You can then type in the same value used is the line rather than creating a series for it.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Thanks for the suggestion -- sounds like a winner.

              --EV

              Comment


                #8
                RyanM,

                Done. Works fine. Thanks.

                The irony is that I had DrawRegion in there to begin with. I took it out because DrawRectangle seemed cleaner and lighter weight. Only after that did I note the problem.

                Oh, well, at least putting it back was fast.

                --EV

                Comment


                  #9
                  Glad to hear this function suits your needs. Thanks for the follow - up.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by ETFVoyageur View Post
                    What I am trying to do is to shade the area between two horizontal lines.

                    Does that require overriding Plot(), or is there a more mainstream way to go?

                    If I do override Plot(), I presume that my idea to just draw the rectangle and have base.Plot() is the way to do?

                    --EV
                    Why not use DrawRegion() then?

                    Comment


                      #11
                      Originally posted by koganam View Post
                      Why not use DrawRegion() then?
                      That's what I am doing now.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by usazencort, Today, 01:16 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post usazencort  
                      Started by kaywai, 09-01-2023, 08:44 PM
                      5 responses
                      603 views
                      0 likes
                      Last Post NinjaTrader_Jason  
                      Started by xiinteractive, 04-09-2024, 08:08 AM
                      6 responses
                      22 views
                      0 likes
                      Last Post xiinteractive  
                      Started by Pattontje, Yesterday, 02:10 PM
                      2 responses
                      21 views
                      0 likes
                      Last Post Pattontje  
                      Started by flybuzz, 04-21-2024, 04:07 PM
                      17 responses
                      230 views
                      0 likes
                      Last Post TradingLoss  
                      Working...
                      X