Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GLFX005, Today, 03:23 AM
        0 responses
        1 view
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        12 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Working...
        X