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

Why does time not follow replay?

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

    Why does time not follow replay?

    Hi there, the time printed, is not following the time of the replay. My code is:

    CalculateOnBarClose = false;
    ...
    if (FirstTickOfBar) {
    Print("First tick of bar, at time " + Time[0] + ", at close " + Close[0]);
    } else {
    Print("At time " + Time[0] + ", at close " + Close[0]);
    }

    I'm replaying the day, tick-by-tick, and my output looks like:

    At time 6/27/2017 10:20:00 AM, at close 2428.75
    At time 6/27/2017 10:20:00 AM, at close 2428.75
    At time 6/27/2017 10:16:03 AM, at close 2428.75
    At time 6/27/2017 10:16:03 AM, at close 2428.75
    At time 6/27/2017 10:20:00 AM, at close 2428.75
    At time 6/27/2017 10:20:00 AM, at close 2428.75
    At time 6/27/2017 10:16:04 AM, at close 2428.75
    At time 6/27/2017 10:16:04 AM, at close 2428.75
    At time 6/27/2017 10:20:00 AM, at close 2429
    At time 6/27/2017 10:20:00 AM, at close 2429
    At time 6/27/2017 10:16:04 AM, at close 2429
    At time 6/27/2017 10:16:04 AM, at close 2429
    At time 6/27/2017 10:20:00 AM, at close 2429
    At time 6/27/2017 10:20:00 AM, at close 2429
    At time 6/27/2017 10:16:05 AM, at close 2429
    At time 6/27/2017 10:16:05 AM, at close 2429
    At time 6/27/2017 10:20:00 AM, at close 2428.75
    At time 6/27/2017 10:20:00 AM, at close 2428.75
    At time 6/27/2017 10:16:06 AM, at close 2428.75
    At time 6/27/2017 10:16:06 AM, at close 2428.75

    I'm replaying on the ES, on a 4 minute bar, but I always get this situation. I don't understand why the times are out of sequence? Since I'm replaying by the second, I would think I would see the printed time increase by one second at a time, with the current price. That is, I'd think the output would be like:

    At time 6/27/2017 10:20:01 AM, at close 2428.75
    At time 6/27/2017 10:20:02 AM, at close 2428.75
    At time 6/27/2017 10:20:03 AM, at close 2428.75
    At time 6/27/2017 10:20:04 AM, at close 2429.00

    Your thoughts? Thanks.
    Attached Files

    #2
    Do you have a secondary dataseries?

    Comment


      #3
      Originally posted by sledge View Post
      Do you have a secondary dataseries?
      I'm pretty sure I don't. But, I am able to break it down. For instance, for just one tick of the bar, an example of output:

      At time 6/27/2017 10:36:00 AM, at close 2429.5
      At time 6/27/2017 10:36:00 AM, at close 2429.5
      At time 6/27/2017 10:33:59 AM, at close 2429.5
      At time 6/27/2017 10:33:59 AM, at close 2429.5

      That is, one tick somehow translates into four statements. The first two have a time always divisible by 4 minutes (am using a 4 minute chart). The second two are accurate, of the current time and market value.

      Comment


        #4
        Hello timmbbo,

        I would also be suspicious of a secondary data series added in your code.

        Could you test the code attached and see if you get the same results I am?

        Demo: https://www.screencast.com/t/L5gtzzwE71k

        I look forward to being of further assistance.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          OK, no surprise, you guys were right about me having multiple data sources. I thought the time would print for only one data source, even though I had multiple.

          New question - how can I specify the data source for FirstTickOfBar? Say my code is:

          Add (PeriodType.Minute, 4);
          Add (PeriodType.Minute, 5);
          Add (PeriodType.Minute, 6);
          ....
          if (FirstTickOfBar) {
          // do something....
          }

          I want the FirstTickOfBar to be calculated on the 4 minute chart, and not the 5 or 6 minute chart. How to do? Thanks

          Comment


            #6
            Originally posted by timmbbo View Post

            I want the FirstTickOfBar to be calculated on the 4 minute chart, and not the 5 or 6 minute chart. How to do? Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by XXtrader, Yesterday, 11:30 PM
            2 responses
            11 views
            0 likes
            Last Post XXtrader  
            Started by Waxavi, Today, 02:10 AM
            0 responses
            6 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            11 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            7 views
            0 likes
            Last Post elirion
            by elirion
             
            Working...
            X