Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Refreshing Plots Automatically

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

    Refreshing Plots Automatically

    In general, how do you make various plots refresh in real time when COBC = false? For example, I am trying to drawtext if the following conditions are true if(High[0] == DonchianChannel(DPeriod).Upper[0] && Close[0] < Open[0]), but it leaves the text hanging if the close was less than open at some point, but now the open is greater than close. I want it to automatically remove the text if the condition is no longer true. Thank you.

    #2
    vegasfoster, you can remove your drawing object if the conditions is negated - http://www.ninjatrader.com/support/h...drawobject.htm

    Or remove all drawing objects with -

    Comment


      #3
      Thanks for the quick response, but I am not understanding how to use it. I am plotting an indicator value using the drawtext. When I put the removedrawobjects after the drawtext code, then nothing plots at all. I want it to plot, I just want the figures to update as changes occur during the bar then when the bar is closed the final figure is plotted.


      if(High[0] == DonchianChannel(DPeriod).Upper[0] && Close[0] < Open[0])
      {

      double MACDValue = Math.Round(MACD(fast, slow, signal).Avg[0]*Multiplier,Rounding);
      string MACDoutput = MACDValue.ToString();
      DrawText(CurrentBar.ToString() + "BarSize",MACDoutput,0,High[0]+VOffset*TickSize,Color.Black);

      RemoveDrawObject(CurrentBar.ToString() + "BarSize");

      }

      This code results in nothing plotting on the historical chart. Thanks again.

      Comment


        #4
        OIC, it has to go before, thanks for your help.

        Comment


          #5
          Sorry, no that's not fixing it.

          Comment


            #6
            vegasfoster, historical would be different than working in realtime and especially in CalculateOnBarClose = false. You'll need to check that your conditions to draw and remove are triggering in both cases, you can split your code for example up by checking with the if (Historical) for both scenarios.

            Comment


              #7
              Ok, so I am breaking into two sections, but even using the remove draw object it is still leaving it there when the condition is no longer true. I can't post the latest code because of your 10000 word limit, but I have tried every combination I can think of and still can't make it work. Either nothing plots or it is still sitting there after the bar closes. Thanks.
              Attached Files

              Comment


                #8
                If I do this, it plots in real time like I want, but it doesn't show historically.

                {

                if(CurrentBar < 20) return;

                if(Historical) return;

                RemoveDrawObject(CurrentBar.ToString() +
                "BarSize");

                if(High[0] == DonchianChannel(DPeriod).Upper[0] && Close[0] < Open[0])

                {

                double MACDValue = Math.Round(MACD(fast, slow, signal).Avg[0]*Multiplier,Rounding);
                string MACDoutput = MACDValue.ToString();

                DrawText(CurrentBar.ToString() +
                "BarSize",MACDoutput,0,High[0]+VOffset*TickSize,Color.Black);
                }


                if(Low[0] == DonchianChannel(DPeriod).Lower[0] && Close[0] > Open[0])

                {

                double MACDValue = Math.Round(MACD(fast, slow, signal).Avg[0]*Multiplier,Rounding);
                string MACDoutput = MACDValue.ToString();

                DrawText(CurrentBar.ToString() +
                "BarSize",MACDoutput,0,Low[0]-VOffset*TickSize,Color.Black);
                }

                }

                Comment


                  #9
                  If I add the following it still doesn't plot historically.

                  {
                  if(CurrentBar < 20) return;

                  if(High[0] == DonchianChannel(DPeriod).Upper[0] && Close[0] < Open[0])

                  {

                  double MACDValue = Math.Round(MACD(fast, slow, signal).Avg[0]*Multiplier,Rounding);
                  string MACDoutput = MACDValue.ToString();

                  DrawText(CurrentBar.ToString() + "BarSize",MACDoutput,0,High[0]+VOffset*TickSize,Color.Black);
                  }


                  if(Low[0] == DonchianChannel(DPeriod).Lower[0] && Close[0] > Open[0])

                  {

                  double MACDValue = Math.Round(MACD(fast, slow, signal).Avg[0]*Multiplier,Rounding);
                  string MACDoutput = MACDValue.ToString();

                  DrawText(CurrentBar.ToString() + "BarSize",MACDoutput,0,Low[0]-VOffset*TickSize,Color.Black);
                  }
                  }

                  Comment


                    #10
                    vegasfoster, you can't return out of the code if it's historical data, then the OnBarUpdate() is for sure not called.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    581 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    338 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    103 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    554 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    552 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X