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 Hwop38, 05-04-2026, 07:02 PM
            0 responses
            164 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            318 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            246 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            350 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            179 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X