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 kinfxhk, 07-14-2026, 09:39 AM
      0 responses
      127 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      85 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      86 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X