Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRectangle with points beyond the chart's right edge

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

    DrawRectangle with points beyond the chart's right edge

    I have an indicator that does a background shade of the Eastern Time lunch period, to easily see when the trading doldrums occur. I’m using DrawRectangle and it’s been successful.

    While I’m in the lunch period, the rectangle drawn is from a past time to an hour or so into the future. But the left edge of the drawing / shading ends before the last two candles / bars. It makes it look as though the lunch period is over all the time. The drawing doesn’t seem to extend off screen into the future. Perhaps that’s behavior you’ve meant to put into DrawRectangle(). But it doesn’t even cover the current candle and the one before. That seems to be an oversight.

    I have used this on a 3 minute bar chart and a 300 tick chart using candles. My “Right Side Margin” is set to 4 and 20 respectively. Both seem to show the same unshaded right edge AND even the problematic unshaded last two bars / candles.

    Could you please let me know the behavior I should expect when using DrawRectangle(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color), especially when startBarsAgo is past and endBarsAgo is future?

    Thanks,

    Brian1

    #2
    I don't know why your rectangle ends 2 candles back but make sure you have Calculate on bar close = false.
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      Brian1,

      You cannot draw into the future. I suggest you use BackColor and just color the background of the chart. Use a time filter to paint the background of every bar that is still in the lunch hour.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Hey thanks eDanny. The change to CalculateOnBarClose to false does now bring the shading to the current bar (no longer two bars back). Sadly, it still cannot draw into the future, making it confusing as to whether this is the last bar of the Lunch period, or not.

        So I've changed it to CalculateOnBarClose = false, at least for now.

        Thanks again.

        Brian1

        Comment


          #5
          Josh: Thanks for the clarification. It now looks like both DrawRectangle & BackColor cannot affect the "white space" between the last / current bar and the right edge.

          I think that it might be nice if this were possible. Manually drawing a Ray on a chart extends beyond the current bar. It's helpful because it does. So please put my request to have DrawRectangle and BackColor behave that way as well. (Although admittedly, it's a minor request.)

          Thanks for your response and clarification. You guys (and gals) are great.

          Brian1

          Comment


            #6
            Thanks for your kind feedback and the suggestions Brian1!

            Comment

            Latest Posts

            Collapse

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