Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ToTime afternoon time parameter not working

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

    ToTime afternoon time parameter not working

    I'm not sure why this is, and I think I've seen others come across this issue, but I am having the following problem:


    Code:
    if (ToTime(Time[0]) >= ToTime(5, 30, 0) && (ToTime(Time[1]) <= ToTime(16, 0, 0))
    I tried to separate it as well:

    Code:
    if (ToTime(Time[0]) >= ToTime(5, 30, 0))
    			{
    				if (ToTime(Time[1]) <= ToTime(16, 0, 0)) { ...
    I've even tried using an exact copy of the ToTime example from help guide.

    Anyways, from 12 to 5, the code is executing fine, no trades are placed. However, the afternoon condition is not met at all until midnight/new day. Trades execute from 16:00:00 right through 23:59. Running latest Ninjatrader7, and running through the Data replay feed.

    Anyone else experience this, or know what might be going on??

    #2
    Try this instead

    if (ToTime(Time[0]) >= ToTime(05, 30, 00) && (ToTime(Time[0]) <= ToTime(16, 00, 00))

    Comment


      #3
      Yeah I did try that (and just tried it again) - no luck. For some reason the afternoon values aren't registering. I'm not sure how to debug with timestamp output (I tried a Print(time[0]) when it entered an order but I don't see any output information for it.

      I'm using 60m candles (1hr). It's weird that it's not just taking trades 1 bar out, it takes them all the way up through midnight. But 12A-5A the time limitation works correctly.

      Comment


        #4
        Print (ToDay (Time[0]) + "," +ToTime(Time[0]) );

        Comment


          #5
          Hello DROCK325,

          Thank you for your post.

          Can you attach the full code to your response?
          You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your strategy > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.

          Comment


            #6
            Patrick - please see attached. I hope it's okay that I removed the entry conditions (they live inside the time filter if statement), I'd rather not have the complete script accessible to all right now (I'd be willing to privately send the file).
            Attached Files

            Comment


              #7
              Hello DROCK325,

              Thank you for your patience.

              I tested your code and I do not see any entries outside of the time frame specified. Can you provide a screenshot of this on your chart?

              Comment


                #8
                Where are you located? What time zone? What are you trying to test trade with?

                Comment


                  #9
                  I spun up some VM's and did a fresh install of NT7 and data download. Ported and tested the code on the VM and the time parameters hold up just fine on both ends. Something with my configuration must be causing the problem. I can still get you a screenshot if you'd like, however.

                  sledge - my timezone is EST (US Eastern), test trading the ES.

                  Can you think of any settings I should check on my end? Maybe the particular data set I started with was causing issues, not sure. I appreciate you checking the code, I had a feeling what little bit I wrote wasn't wrong..

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by f.saeidi, Today, 12:14 PM
                  4 responses
                  11 views
                  0 likes
                  Last Post f.saeidi  
                  Started by Russ Moreland, Today, 12:54 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Started by philmg, Today, 12:55 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Started by TradeForge, 04-19-2024, 02:09 AM
                  2 responses
                  32 views
                  0 likes
                  Last Post TradeForge  
                  Started by aprilfool, 12-03-2022, 03:01 PM
                  3 responses
                  329 views
                  0 likes
                  Last Post NinjaTrader_Adrian  
                  Working...
                  X