Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing a dynamic rectangle on another panel

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

    Drawing a dynamic rectangle on another panel

    Hello!

    I am trying to draw a dynamic rectangle on a panel other that that of the chart.

    I have the following codes:

    HTML Code:
    Draw.Rectangle(this, "tag1", false, Time[500], 100.00, Time[0], 80, areaColor,  AreaOpacity);
    In this code, I want the rectangle to start from Bar[500] to Bar[0].

    I have also tried with OnRender() as followed:
    HTML Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        if (IsInHitTest) return;
        else base.OnRender(chartControl, chartScale);
                
        if(Bars == null || ChartControl == null)
         return;
    
        float xCandStart  = chartControl.GetXByBarIndex(ChartBars, 500);
    
       SharpDX.RectangleF vecLevel1 = new SharpDX.RectangleF(xCandStart, 100.00, 500, 20);
       RenderTarget.FillRectangle(vecLevel1, level1ColorDx);​​
    }​
    I am not seeing any rectangle on the chart.

    I would appreciate any help.
    Last edited by Stanfillirenfro; 05-28-2024, 08:07 AM.

    #2
    Hello Stanfillirenfro,

    The drawing can only go to another panel if the indicator resides in that panel and you are using DrawOnPricePanel = false.



    OnRender has no supported means to draw outside the panel that the indicator resides in.

    Comment


      #3
      Many thanks NinjaTrader_Jesse for your reply.
      The drawing can only go to another panel if the indicator resides in that panel and you are using DrawOnPricePanel = false.
      It is exactly what I have done.
      OnRender has no supported means to draw outside the panel that the indicator resides in.
      The idea here is to draw rectangle in the oversold region of Stochastic. This indicator is plotted on another panel than that of the chart.
      I have the stochastic drawn, but not the rectangle.

      Any help?

      Comment


        #4
        Hello Stanfillirenfro,

        You would need to move the indicator into the same panel as the stochastic in that use case, for it to draw or render in that panel it needs to reside in that panel. You can overlay the indicator in the same panel as the stochastic by dragging it into that panel. If this is a custom strategy it would be easiest to incorporate the stochastic into your indicator and then have the strategy add your custom indicator, your custom indicator would be plotting the stochastic in addition to your other plots/drawings.

        Comment


          #5
          Many thanks NinjaTrader_Jesse for your reply.
          I have a custom indicator i wgich I have incorporated the stochastic (see picture). The stochastic is plotted easyly, but the rectangle is missing.
          Is there smething t be changed in the codes?​
          Attached Files

          Comment


            #6
            Hello Stanfillirenfro,

            Did you make sure to set DrawOnPricePanel = false and re apply the indicator after doing so? Drawing objects will only appear in that panel if that is set to false. You would also need to verify the value you are providing to the drawing object are valid, you can open the drawing tools window to see if the object was drawn to the chart and what values it has.

            For custom rendering using OnRender you would need to make sure the x and y values you use were calculated from bar and price data to get the correct coordinates.

            Comment


              #7
              Many thanks NinjaTrader_Jesse for your reply.

              AWSOME!!!!!!!

              DrawOnPricePanel was not set to false. Now it is and I have my rectangle!

              Many thanks again NinjaTrader_Jesse for your help!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              605 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              351 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              560 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              561 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X