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

ToDay() && ToTime()

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

    ToDay() && ToTime()

    Hello,
    I'm trying to debug my code and I'd like to narrow down the area that I search so I don't have to scroll so much through the Output Window. I'm wondering if there is a way to use the ToDay() and ToTime() together to pick specific days and times. I've tried encapsulating my code with the these methods but nothing returns in the Output Window. Can someone help me with this please?
    Thanks

    #2
    Post your code for review and what you are hoping it does.

    Comment


      #3
      Hello CaptainAmericaXX,

      Thank you for your post.

      Are you using Print() for the values?
      Are you checking ToDay() and ToTime() in a condition?

      Can you provide the code you use for Print(), ToDay(), ToTime(), and any conditions used for these items?

      Comment


        #4
        Thank you for the reply's. Here is a section of the code.
        Code:
        if(ToDay(Time[0]) > 2015107 && ToDay(Time[0])< 2015108) 
                    {
                    if(Close[0] > Close[1] && !established_swing_low)
                    {
                        current_swing_low = Low[0];//establish swing low
                        Print(Time[0] + " Swing Low is " + Low[0]);
                        established_swing_low = true;
                     }
           
                    if(Close[0] < current_swing_low && established_swing_low )
                    { 
                        established_swing_low = false;
                        Print(Time[0] +" Swing was broken at " + Close[0]);
                        top_of_first_leg = current_swing_low;
                        lower_high = current_swing_low;
                        first_leg = true;
                        second_leg = true;
                        after_second_leg = true;
                        after_first_leg = true;
                        Print("SWING LOW RESET");
                    }
                    }
        Thanks

        Comment


          #5
          Originally posted by CaptainAmericaXX View Post
          Thank you for the reply's. Here is a section of the code.
          Code:
          if(ToDay(Time[0]) > 2015107 && ToDay(Time[0])< 2015108)
          Is that October 7 and October 8?
          There's no day in between? Did you want only 10/7? Try >= instead of >

          Also Do a print statement before on the ToDay ().

          (Sorry on mobile, can't dig further)

          Comment


            #6
            Sledge, thanks for the help. Unfortunately adding a day and adding <= did nothing. I tried a Print() with just the ToDate() and got nothing. I'm not showing any errors in the log.
            if(ToDay(Time[0]) >= 2015107 && ToDay(Time[0])<= 2015109)

            {
            Print("This is working");
            }
            Any other suggestions?

            Comment


              #7
              Originally posted by CaptainAmericaXX View Post
              Sledge, thanks for the help. Unfortunately adding a day and adding <= did nothing. I tried a Print() with just the ToDate() and got nothing. I'm not showing any errors in the log.

              Any other suggestions?
              Put the Print before the IF statement with the ToDay Time..

              Your output log will fill up, but you will see your error in your logic.



              Code:
              Print ("The Day is:" + ToDay(Time[0])) ;
              
              if(ToDay(Time[0]) >= 2015107 && ToDay(Time[0])<= 2015109) 
              
              {
              Print("This is working");
              }

              Comment


                #8
                Silly Rabbit! Trix are for kids! (Does the commercial state that any more?). Thanks for working with me on this Sledge. I discovered that 20151007 will work while 2015107 won't. I forgot to add a 0 before the 7. Silly me.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by JoMoon2024, Today, 06:56 AM
                0 responses
                6 views
                0 likes
                Last Post JoMoon2024  
                Started by Haiasi, 04-25-2024, 06:53 PM
                2 responses
                19 views
                0 likes
                Last Post Massinisa  
                Started by Creamers, Today, 05:32 AM
                0 responses
                6 views
                0 likes
                Last Post Creamers  
                Started by Segwin, 05-07-2018, 02:15 PM
                12 responses
                1,786 views
                0 likes
                Last Post Leafcutter  
                Started by poplagelu, Today, 05:00 AM
                0 responses
                3 views
                0 likes
                Last Post poplagelu  
                Working...
                X