Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding and Removal of Draw.Text

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

    Adding and Removal of Draw.Text

    Hi,

    When a specific condition is met for a bar, I number it like this:

    Code:
    if condition is true
    {
    Draw.Text(this, "tag1"+CurrentBar, true, "1", 0, Low[0] - ((ATR(14))[0]/2), 20, Brushes.Lime, new SimpleFont("Arial", 12),TextAlignment.Center,Brushes.Transparent, Brushes.Transparent, 0);
    }
    When the next bar is born, and that the condition is also satisfied, I number it like this:

    Code:
    if condition is true
    {
    Draw.Text(this, "tag1"+CurrentBar, true, "1", 1, Low[0] - ((ATR(14))[0]/2), 20, Brushes.Lime, new SimpleFont("Arial", 12),TextAlignment.Center,Brushes.Transparent, Brushes.Transparent, 0);
    
    Draw.Text(this, "tag1"+CurrentBar, true, "2", 0, Low[0] - ((ATR(14))[0]/2), 20, Brushes.Lime, new SimpleFont("Arial", 12),TextAlignment.Center,Brushes.Transparent, Brushes.Transparent, 0);
    }
    I continue like so until I get to number 5, however, if bar number 3 does not meeting the required condition, I would like the remove the Draw.Text above.
    Any ideas how I can remove them ?
    As it stands, my number 1 and 2 will stay on the chart, but I am not interested in seeing them on the chart anymore.... because bar 3 did not meet my requirement
    Last edited by akvevo; 11-17-2017, 01:44 AM.

    #2
    Hello akvevo,

    Thanks for opening the thread.

    Drawing objects can be removed by calling RemoveDrawObject() with the tag of the draw object you would like removed.

    You could create some strings to hold the tags for your drawing objects, and then you could use those strings within RemoveDrawObject() to remove the desired draw object.

    I've included a link to our publicly available documentation on RemoveDrawObject() - https://ninjatrader.com/support/help...drawobject.htm

    If you have any additional questions, please don't hesitate to ask.

    Comment


      #3
      Thanks Jim,

      Can you kindly give me more information around :

      you could create some strings to hold the tags for your drawing objects
      Or perhaps a brief example ?
      I am currently using :

      Code:
      "tag1"+CurrentBar
      for each annotation.
      Are you imply that I would need to specifically name the CurrentBar?
      Any detail and insight would be greatly appreaciated

      Thanks

      Comment


        #4
        Hello akvevo,

        Drawing objects accept a string for the tag argument. You are already passing the string "tag1"+CurrentBar when you call Draw.Text(). My suggestion was to create your own variable of type string so you can keep track of these strings and then remove them with RemoveDrawObject() when you deem appropriate.

        The following code assigns the text "tag"+CurrentBar to a variable of type string.
        Code:
        protected override void OnBarUpdate()
        {
        	if (CurrentBar < 14)
        		return;
        	string myString = "tag"+CurrentBar;
        	Print(myString);
        	Draw.Text(this, myString, true, "1", 0, Low[0] - ((ATR(14))[0]/2), 20, Brushes.Lime, new SimpleFont("Arial", 12),TextAlignment.Center,Brushes.Transparent, Brushes.Transparent, 0);
        }
        You may find programming resources on variables and syntax from the NinjaTrader 7 help guide or from externally available resources on C#. I'll include a link to what we have openly available in the NT7 help guide.

        NinjaTrader 7 programming concepts - https://ninjatrader.com/support/help...sic_syntax.htm

        Please let us know if you need further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X