Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Removing Draw Text?

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

    Removing Draw Text?

    Could some help me with this. I'm trying to remove the last draw text! It will draw the the text, but can't seem to remove it?

    private int lastPBar = 0;
    private int thisPBar = 0;



    if (CurrentBar ==0)
    return;
    if(PU[0] < PU[1])
    {
    if(PU[0] == 100000)
    lastPBar = 0;
    else
    {
    lastPBar = thisPBar;
    }

    thisPBar = CurrentBar;

    Draw.Text(this,"PUp"+CurrentBar.ToString(), true,"P", 0,
    Low[0]-LabelOffset*TickSize,0, Brushes.Green, trifont,
    TextAlignment.Center, Brushes.Transparent,
    Brushes.Transparent, 1);
    if(lastPBar >0)
    RemoveDrawObject("PUp"+ (CurrentBar-lastPBar));
    }
    Thanks,

    #2
    Hello woodyfox,

    I'm not certain that I am understanding.

    Are you trying to draw an object and then immediately remove that object on the same bar?

    If you print the string you are using does this match the tag name of the drawn object?

    (Likely the CurrentBar value is changing)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      No, the last draw.text under same tag

      Comment


        #4
        Hello woodyfox,

        With the code provided it appears that the Drawing object will be removed on the same bar it is drawn on if lastPBar is greater than 0.

        Please provide the output from the prints.

        What is the output from the string used for RemoveDrawObject?

        What is the tag of the drawn object?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea, Could you be so kind to provide an example where a bar value is stored at CurrentBar and then can be referenced at a later time? (to remove draw.text) Im hoping there is an existing indicator I can use as an examlple.
          Thanks,

          Comment


            #6
            Hello woodyfox,

            Unfortunately, I am not aware of a specific script that has custom logic to remove drawing objects by storing the CurrentBar number.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              OK. Any hints, Tips, etc. Someone has had to ask if its possible to remove prior bars Draw.Text. Any examples on forum. Any help would be helpful.
              Thanks,

              Comment


                #8
                Chelsea,
                Disregard last entry. I figured it out, my code had a small mistype. Thanks anyway.

                Comment


                  #9
                  Hello woodyfox,

                  Its always helpful to debug the code by using prints. This would be the fastest way to fix the code to what you are wanting.

                  Below is a link to a forum post that demonstrates using prints to understand behavior.


                  After some research I found the AutoTrendHNT8 indicator included with the AutoTrendHDemoNT8 strategy on the forums stores bar numbers and uses this to remove drawing objects.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by SalmaTrader, 07-07-2026, 10:26 PM
                  0 responses
                  30 views
                  0 likes
                  Last Post SalmaTrader  
                  Started by CarlTrading, 07-05-2026, 01:16 PM
                  0 responses
                  17 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CaptainJack, 06-17-2026, 10:32 AM
                  0 responses
                  9 views
                  0 likes
                  Last Post CaptainJack  
                  Started by kinfxhk, 06-17-2026, 04:15 AM
                  0 responses
                  16 views
                  0 likes
                  Last Post kinfxhk
                  by kinfxhk
                   
                  Started by kinfxhk, 06-17-2026, 04:06 AM
                  0 responses
                  19 views
                  0 likes
                  Last Post kinfxhk
                  by kinfxhk
                   
                  Working...
                  X