Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time of day?

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

    #16
    Thanks for the catch on that code, I should of been more careful...

    I did some troubleshooting and found that Ninja does follow the first time rule, but not the second. I confirmed this by running a strategy from 2am to 8am in a template that went from 6am to 8am - all trades happened within 6 to 8. However on the default templates, it goes from 2am to the close.

    I went back to my strategy, and checked that the code was correct and that I compiled it... I have this:
    & ToTime(Time[0]) >= ToTime(2, 0, 0)
    && ToTime(Time[0]) <= ToTime(8, 0, 0)

    The first rule will be followed, but not the second (apparently). I'm wondering hwat I'm screing up...

    Also, I've found that both ToTime(6,0,0) and 60000 produce the same results (follows the first >= rule, not the second <= rule).

    Comment


      #17
      Update --

      after further work on the issue, I find that the strategy works on some contracts, but not on others.It looks like there is a bug hiding somewhere having to do with just some contracts. I'm going to reinstall NT and see what happens.

      Comment


        #18
        Originally posted by gg007 View Post
        No, Ninjatrader has bugs, and is placing orders outside of the specified times.

        You say you won't debug strategies, although that wasn't what I was asking... I can't simplify the 10 lines of example code I wrote anymore; if you looked at it you would know that. The code is so simple, I can say it in one breath:

        if (SMA(14)[0] > EMA(14)[0]
        && ToTime(Time[0]) >= ToTime(17, 33, 19)
        && ToTime(Time[0]) >= ToTime(18, 33, 19))
        {
        EnterLong(1, "Buy test14");
        }
        if (SMA(14)[0] < EMA(14)[0]
        && ToTime(Time[0]) >= ToTime(17, 33, 19)
        && ToTime(Time[0]) <= ToTime(18, 33, 19))
        {
        ExitLong("Sell test14", "Buy test14");
        }


        I gave two screenshots and two example codes that it does not work. I suggest you try to replicate it with the code I provided, then try your own strategies, before blaming me and the two simple examples I provided- Unless Ninjatrader has never had a disastrous bug before and you believe it's absolutely impossible for there to be something wrong with NT source code, especially at $180/mo.

        I was wondering if I should move on and not worry about the NT bug, or if I was not following the correct instructions. It seems very clear that NT is bugged in this respect. Maybe no one has rose the issue because no one uses an obscure feature like time. All I really asked was to move on or be corrected with what I was doing wrong.
        As far as I can see for now, the bug is in your code.

        Here is your first time filter:

        Code:
        [SIZE="2"][I]if (SMA(14)[0] > EMA(14)[0]
                        && ToTime(Time[0]) >= ToTime(17, 33, 19)
        				&& ToTime(Time[0]) >= ToTime(18, 33, 19))
                    {
        				EnterLong(1, "Buy test14");
                    }
        It says essentially to go long if the SMA cross happens and the time is at or AFTER 18:33:19, as the first part of the time filter will be identically true if the second part is true. Is that not what you are seeing?

        Comment


          #19
          Originally posted by koganam View Post
          As far as I can see for now, the bug is in your code.

          Here is your first time filter:

          Code:
          [SIZE="2"][I]if (SMA(14)[0] > EMA(14)[0]
                          && ToTime(Time[0]) >= ToTime(17, 33, 19)
          				&& ToTime(Time[0]) >= ToTime(18, 33, 19))
                      {
          				EnterLong(1, "Buy test14");
                      }
          It says essentially to go long if the SMA cross happens and the time is at or AFTER 18:33:19, as the first part of the time filter will be identically true if the second part is true. Is that not what you are seeing?
          I already discussed this before.

          I was going to make another post, but gave up. Anyways here is what I found:
          • Using the format
            Code:
             if (time xxx) { if (strategy / time) { order } }
            is the only way it will function.
            Code:
            if {strategy totime[xxx] { order }
            does not function.
          • The strategy (and any others I make) will execute correctly the specified time period on some contracts, but not others. Why is this? A bug in the ninjascript?
          • On the contracts where the time clause does not function, it only ignores the <= timeofday clause. In other words, it starts trades at the beginning of the time period, and goes to the close - not the end of the time period.


          I suggest making your own strategy and testing it on multiple contracts if you want to see the problem. I found it to not work on TF but correctly work on ZC, among others.

          Comment


            #20
            I get consistent, expected results on any instrument. I'm happy to run the exact same scenario and compare results with you.

            Can you please let us know the following:
            • What version are you using? Check this using Help > About.
            • Are you compiling your code changes by Right Clicking > Compile?
            • Are you running a new report after making any code changes?


            Please provide strategy settings for one example where this does not work as you expect:
            • Interval type and value
            • Date range
            • Instrument
            • Session Template.
            • Data Provider.
            • Computer time zone. (Also good to check that your time and time zone are set accurately)


            Please confirm you're using the snippet posted here when seeing these results and not your earlier one with coding errors.

            Thanks for your help getting this information.
            Last edited by NinjaTrader_RyanM1; 04-20-2012, 01:05 PM.
            Ryan M.NinjaTrader Customer Service

            Comment


              #21
              setting CST on charts

              where do I set the CST time on nt 7 on the charts plez?

              Comment


                #22
                laredo78676, NT will use your PC clock and time zone for the chart display.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #23
                  Is there anybody there who knows how to integrate time filter in indicator? I want my indicator to draw dot on the chart when the chart time is 8am or 080000. Any ideas would be appreciated. Thanks

                  Comment


                    #24
                    Hello luxurious_04,
                    You can use the below code to filter your code at a specified time

                    Code:
                    if (ToTime(Time[0]) == 80000)
                    {
                       //do something
                    }
                    http://www.ninjatrader.com/support/h...tml?totime.htm

                    Please note the above code will work on a 1, 2 , 5 10 etc minute chart, where you are sure that a bar with a timestamp at 8:00AM exits.
                    JoydeepNinjaTrader Customer Service

                    Comment


                      #25
                      Actually, I already figure it out. Anyway, thank you so much NinjaTrader_Joydeep

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by llanqui, Today, 07:11 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post llanqui
                      by llanqui
                       
                      Started by llanqui, Today, 06:42 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post llanqui
                      by llanqui
                       
                      Started by dtaylor, Yesterday, 03:52 PM
                      1 response
                      12 views
                      0 likes
                      Last Post Tasker-182  
                      Started by vapala, Today, 06:22 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post vapala
                      by vapala
                       
                      Started by Carlos19, Today, 06:18 AM
                      0 responses
                      7 views
                      0 likes
                      Last Post Carlos19  
                      Working...
                      X