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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      164 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      319 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      246 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X