Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Increment time value of an IText object

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

    Increment time value of an IText object

    Hi all

    I am trying to update the time property of a text object on the chart.

    This is what I wrote

    Code:
    [SIZE=2]        protected override void OnBarUpdate()
            {
                    
                    foreach (IDrawObject draw in DrawObjects)
                    {
                        if (draw.Tag.Contains("TextTag"))
                        {
                            IText text = (IText) draw;
                              if(BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value == 5){text.Time.AddMinutes(5);}
                            if(BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value == 15){text.Time.AddMinutes(15);}
                            if(BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value == 30){text.Time.AddMinutes(30);}
                            if(BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value == 60){text.Time.AddMinutes(60);}
                            if(BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value == 240){text.Time.AddMinutes(240);}
                            if(BarsPeriod.Id == PeriodType.Day && BarsPeriod.Value == 1){text.Time.AddDays(1);}
    
                        }
                    }
            }[/SIZE]
    But text.Time.AddMinutes does not increment the time value? Any suggestions?
    Last edited by traderji; 09-20-2011, 01:43 PM.

    #2
    Hello traderji,

    You can modify the properties of drawing objects like this only for code placed text, and not manually drawn text.

    Then, you would use the IText interface directly rather than go through all items in DrawObjects collection.

    If your code placed draw object is named text, you could use this example to move it 30 minutes. There needs to be some additional control here so that it's not simply moved 30 minutes after the first move.

    if (Time[0] == text.Time.AddMinutes(30))
    text.BarsAgo = 0;
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan. Cheers.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X