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

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 kevinenergy, 02-17-2023, 12:42 PM
      118 responses
      2,778 views
      1 like
      Last Post kevinenergy  
      Started by briansaul, Today, 05:31 AM
      0 responses
      9 views
      0 likes
      Last Post briansaul  
      Started by traderqz, Yesterday, 12:06 AM
      11 responses
      28 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by PaulMohn, Today, 03:49 AM
      0 responses
      9 views
      0 likes
      Last Post PaulMohn  
      Started by inanazsocial, Today, 01:15 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Jason  
      Working...
      X