Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Time

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

    Using Time

    I'm wondering why the following code is not working. I'm trying to draw text on the bottom left hand side of panel 1 if the current time is between a start and end time.

    At the moment this code display these text "Check news" all of the time.

    Code:
      protected override void OnBarUpdate()
            {  
            // If time is between 11:08 AM and 11:10 AM, draw text in the bottom left corner of panel 1    
                if (ToTime(Time[0]) >= 110800 && ToTime(Time[0]) <= 111000) 
                    {
                    DrawTextFixed("BoxBottom",("Check news"), TextPosition.BottomLeft, Color.Black, new Font("Arial", 14), Color.Blue, Color.GreenYellow, 7);
                    }   
            }

    #2
    Originally posted by suprsnipes View Post
    I'm wondering why the following code is not working. I'm trying to draw text on the bottom left hand side of panel 1 if the current time is between a start and end time.

    At the moment this code display these text "Check news" all of the time.

    Code:
      protected override void OnBarUpdate()
            {  
            // If time is between 11:08 AM and 11:10 AM, draw text in the bottom left corner of panel 1    
                if (ToTime(Time[0]) >= 110800 && ToTime(Time[0]) <= 111000) 
                    {
                    DrawTextFixed("BoxBottom",("Check news"), TextPosition.BottomLeft, Color.Black, new Font("Arial", 14), Color.Blue, Color.GreenYellow, 7);
                    }   
            }

    After you put the Fixed Text you have to remove it when conditions are no longer met.
    RemoveDrawObject("BoxBottom");

    Comment


      #3
      Thanks for your reply Roonius, but how do I remove it? And where would I place the code?

      Comment


        #4
        Hi Suprsnipes,

        Add the snippet below to remove your box when you're not using it. This goes after the last closing bracket } of your if statement.

        Code:
        else
        {
        RemoveDrawObject("BoxBottom"); 
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Really appreciate the help guys.

          This is the code, however, it does not behave as expected...

          The "BoxBottom" text still remains.

          Code:
           protected override void OnBarUpdate()
                  {            
                  // Time between 12:01 PM and 12:03 PM    
                      if (ToTime(Time[0]) >= 120100 && ToTime(Time[0]) <= 120300) 
                          {
                          DrawTextFixed("BoxBottom","Check news", TextPosition.BottomLeft, Color.Black, new Font("Arial", 14), Color.Blue, Color.GreenYellow, 7);
                          }
                              else
                              {
                                  RemoveDrawObject("BoxBottom"); 
                              }
                  }

          Comment


            #6
            Ok, the code is working no problems (I had it on an instrument that wasn't trading any volume)

            Thanks alot for your help Roonius and NinjaTrader_RyanM.

            Originally posted by suprsnipes View Post
            Really appreciate the help guys.

            This is the code, however, it does not behave as expected...

            The "BoxBottom" text still remains.

            Code:
             protected override void OnBarUpdate()
                    {            
                    // Time between 12:01 PM and 12:03 PM    
                        if (ToTime(Time[0]) >= 120100 && ToTime(Time[0]) <= 120300) 
                            {
                            DrawTextFixed("BoxBottom","Check news", TextPosition.BottomLeft, Color.Black, new Font("Arial", 14), Color.Blue, Color.GreenYellow, 7);
                            }
                                else
                                {
                                    RemoveDrawObject("BoxBottom"); 
                                }
                    }

            Comment


              #7
              Alternative solution

              See here

              Produced by Roonius himself - a masterclass in NS - very useful and completely non intrusive

              Comment


                #8
                Thanks alot Mindset

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by JTizz, Today, 01:20 PM
                0 responses
                2 views
                0 likes
                Last Post JTizz
                by JTizz
                 
                Started by omermirza, Today, 12:39 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Jim  
                Started by mballagan, Today, 01:02 PM
                0 responses
                4 views
                0 likes
                Last Post mballagan  
                Started by larkmail, Today, 12:30 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_Kate  
                Started by Danila, Today, 11:08 AM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X