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

Wierd Time[0] value in OnExecution

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

    Wierd Time[0] value in OnExecution

    Greetings,

    I have the following output in my log:

    Timestamp is taken from Time[0]

    2011-12-09 19:16:20: barsInProgressIndex#0
    2011-12-09 19:16:20: barsInProgressIndex#0
    2011-12-09 19:16:20: barsInProgressIndex#1
    2011-12-09 19:16:20: barsInProgressIndex#1
    2011-12-09 19:18:24: barsInProgressIndex#1 ...
    2011-12-09 19:18:24: barsInProgressIndex#1 ...
    2011-12-09 19:19:19: barsInProgressIndex#1
    2011-12-09 19:19:19: barsInProgressIndex#1
    2011-12-09 19:21:39: barsInProgressIndex#1
    2011-12-09 19:21:39: barsInProgressIndex#1
    2011-12-09 19:24:23: barsInProgressIndex#1
    2011-12-09 19:24:23: barsInProgressIndex#1
    2011-12-09 19:26:10: barsInProgressIndex#1
    2011-12-09 19:26:10: barsInProgressIndex#1 # after this EnterShort(1, ...) gets called
    2011-12-09 19:26:10: barsInProgressIndex#1, signal confirmed, entering Sell
    2011-12-09 19:16:20: Order 19:26:10 filled # comes from OnExecution

    The question is: how come the timestamp on the last message is different from the timestamp of the bar that had issued the entry order?

    Note, that there are 2 data series based on volume on the chart, both represent the same instrument but with different volume values. The order is issued sometimes via EnterShort(0, ..., sometimes via EnterShort(1,

    Since at 19:26:10 we had issued the order as EnterShort(1, then why 19:16:20 bar (barsInProgressIndex#0 bar) is mentioned upon a fill?
    Last edited by alex.nt; 12-15-2011, 10:43 AM.

    #2
    Hi alex.nt,

    Please make sure you are using the latest version of NT, release 8. There was this fix that may be related.
    Fixed 4576 Charts Executions of non-primary series of multi-series strategies could be on wrong bar index of series.

    If you are unsure about any output from your strategy after upgrading, please post a simplified code snippet that generates the output.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I have just installed the latest version and the problem persists...

      The code is very simple:
      1. print message before sending a market order
      2. Print message in OnExecution like:
      protected override void OnExecution(IExecution execution)
      {
      if (execution != null && execution.Order != null && execution.Order.OrderState == OrderState.Filled)
      {
      Log("Order " + execution.Name + " filled"); // <----- weird time
      }
      }

      I think this may be related to the fact that I use 2 charts (onBarUpdate gets called for one and for another so may be onExecution still thinks in terms of slow chart, which can be behind)...

      Comment


        #4
        I don't see where time is used anywhere in your example code. Are you talking about the timestamp that's included when generating a log statement?
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Yes, the timestamp is prepended to the message in Log function.

          Comment


            #6
            The log time appended is the local system time.

            The log time you are comparring it to the right on that last line does not look like you are accessing the correct time value.

            You are doing Log("Order " + execution.Name + " filled");

            You should be using:

            Log("Order " + execution.Time + " filled");

            Finally, please be carefull with logging. We prefer using the output window and the Print command for this logging as if there are too many lines in the log this will cause performance issues in NinjaTrader.

            -Brett

            Comment


              #7
              Hi Brett,
              Ok, here is the log function:
              public void Log(string s)
              {
              string pre = string.Format("{0:yyyy-MM-dd HH:mm:ss}", Time[0]) + ": ";
              Print(pre + s);
              }

              Comment


                #8
                Hello,

                Looks like you are overriding the log output.

                This would be unsupported and would not recommend doing this, this may be a contributing factor for why your time is not correct. Would recommend using the standard log method.

                -Brett

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,602 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                8 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                4 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                12 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X