Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rewrite draw.text with same tag but without position

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

    Rewrite draw.text with same tag but without position

    hi,, as topic is possible?

    examples:

    1) Draw.Text(this, lastTag, false, "Tp " + Mp.tpFc1, bar, scr, 1, Brushes.RoyalBlue, myFont, TextAlignment.Right, null, null, 80);

    ok...

    if i want to rewrite in the same tag.....can i use :

    2) Draw.Text(this,lastTag.... but without specify position bar?

    if is not possibile ...how i can to recover information bar by DrawText ?

    #2
    Hello,

    I wanted to check and make sure I understand the question.

    Are you asking how to re use the same Tag without specifying the remainder of the parameters?

    If this is not correct, can you provide further description?

    You can store the Draw.Text as a variable, to do so and then later get the values from it you could use the following example:

    Code:
    Text myText = Draw.Text(this, "MyText", "Sample text", 0, High[0] + 2 * TickSize, Brushes.Blue);
    Text myOtherText = Draw.Text(this, myText.Tag, "Some Other Text", myText.Anchor.BarsAgo, myText.Anchor.Price, Brushes.Red);
    This simply re uses the tag from the first text to re set the original text by calling Draw.Text with the same tag.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      there is a problem...

      if i draw 200 bar later....if i use the same instance is not correct..

      myText.Anchor.BarsAgo ....200 bar later..is not correct as value....

      I want rewrite in the same position the old Draw

      Comment


        #4
        Hello,

        Thank you for the clarification.

        If you only want to update the existing object, you can but you need to provide it with the information it needs to stay in place.

        One way is to use the Time rather than a bars ago. A BarsAgo would relate to the CurrentBar where a Time is a specific point in the axis. Here is a simple example using the Time overload set:

        Code:
        Text myText;
        protected override void OnBarUpdate()
        {
        	if(CurrentBar == 0)
        		myText = Draw.Text(this, "MyText", "Sample text", 0, High[0] + 2 * TickSize, Brushes.Blue);
        	if(CurrentBar > 0)
        		Draw.Text(this, myText.Tag,true, "Some Other Text", myText.Anchor.Time, myText.Anchor.Price, 0, Brushes.Red, new SimpleFont(), TextAlignment.Left, Brushes.Black, Brushes.Blue, 100);
        }
        This would place an object on bar 0, the object remains at bar 0 but then is updated on each OnBarUpdate call.

        Depending on the property you want to change, you may also be able to update only that property using the instance of the object:

        Code:
        myText.Anchor.Price = Close[0];
        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ender_wiggum, Today, 09:50 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by rajendrasubedi2023, Today, 09:50 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by geotrades1, Today, 10:02 AM
        0 responses
        4 views
        0 likes
        Last Post geotrades1  
        Started by bmartz, Today, 09:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by geddyisodin, Today, 05:20 AM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X