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 TraderBCL, Today, 04:38 AM
      2 responses
      7 views
      0 likes
      Last Post TraderBCL  
      Started by martin70, 03-24-2023, 04:58 AM
      14 responses
      105 views
      0 likes
      Last Post martin70  
      Started by Radano, 06-10-2021, 01:40 AM
      19 responses
      606 views
      0 likes
      Last Post Radano
      by Radano
       
      Started by KenneGaray, Today, 03:48 AM
      0 responses
      4 views
      0 likes
      Last Post KenneGaray  
      Started by thanajo, 05-04-2021, 02:11 AM
      4 responses
      471 views
      0 likes
      Last Post tradingnasdaqprueba  
      Working...
      X