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

Accessing TimeStamp of a Tick

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

    Accessing TimeStamp of a Tick

    After issuing an order, I want to wait a set amount of time then cancel any infilled entry orders. I'm currently using

    OrderTime=Time[0];

    Is there a way to access TickTime, something like:

    Ordertime=TickTime();

    If I use:

    OrderTime=DateTime.Now; won't that mess up backtesting?

    #2
    imported post

    Tom,

    - Datetime.Now will mess up backtesting
    - Time[0] will be in the future for time based series (e.g. end of the minute for 1 minute series)
    - Time[0] is the timestamp of the current tick on Vol and Tick series. However: with latest beta OnBarUpdate is not (!) triggered right away as a new tick comes in but later (triggered asynchronously). This will change with next beta.

    -> if you are dependent on that feature, then you should wait for next beta,

    Comment


      #3
      imported post

      Dierk,
      Thanks,
      I am using OrderTime=Time[0] now for Vol Charts, and it works as expected (I think). I was thinking ahead to use the same logic on Time charts. To simulate STOPLIMIT with negative offset, and Cancel after 2.5 minutes.

      This code is for a Vol chart. Will the same Idea work for Minute charts, or does the EnterLongLimit only get processed at barClose?
      Can I also make it work this way for a Minute Chart?
      [line]
      CalculateOnClose=false;

      //Determine Entry points on a once per bar basis
      if(FirstTickOfBar)
      {
      BuyOrderPrice=OP;
      }
      // Process Entry Orders on a Tick by Tick basis
      if ( High[0] >=OP )
      {
      // Simulated STOPLIMIT, negative offset
      EnterLongLimit(Op-TickSize, . . . StrategyId);
      OrderTime=Time[0] ; // Assume place a Limit Order at 1:01:10
      }

      if (Position.MarketPosition != MarketPosition.Flat
      && Time[0]>OrderTime.AddMinutes(2.5)) // At 1:03:40
      {
      OP=0; // Stops submitting the EnterLongLimit, > CANCEL
      }

      Comment


        #4
        imported post

        Not sure. Please be aware that OrderTime is a time in the future for minute bars, which is different than for Vol/Tick series where it's the time of the last tick.

        Comment


          #5
          imported post

          Right, that is why I wanted to access the TickTime on the Tick that triggers the Order.

          If I could Set OrderTime to the time of the triggering tick, then I think this code will work for Vol, Tick, and Minute charts

          SomeThing like

          OrderTime=TickTime();

          Comment


            #6
            imported post

            I guess you are stretching the concept a bit too far, meaning your backtesting part will behave diffrently than the realtime part of the strategy.

            Here is why:
            - backtested orders are placed after close of the bar -> OrderTimewill be the timestamp of the bar on close
            - on realtime: OrderTime will be the actual tick timestamp (Vol/Tick series) or the timestamp of the bar on close (in the future for e.g. minute series)

            -> your backtest result will not be reproducible realtime. I suggest rather going by "bars to wait" until next action is taken, instead of absolute "time to wait"

            Comment


              #7
              imported post

              Ok,
              Thanks for the detailed explanation. I can live with Backtest being different than real time (it always is anyway, even with best intentions).

              I take it that Access to TickTime is not available, and not likely to become available. I'll adjust my thinking.

              thanks for your response.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ScottW, Today, 06:09 PM
              0 responses
              2 views
              0 likes
              Last Post ScottW
              by ScottW
               
              Started by Board game geek, 10-29-2023, 12:00 PM
              14 responses
              244 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Waxavi, 04-19-2024, 02:10 AM
              4 responses
              56 views
              0 likes
              Last Post sonia0101  
              Started by cmtjoancolmenero, Today, 03:58 PM
              0 responses
              9 views
              0 likes
              Last Post cmtjoancolmenero  
              Started by Segwin, 05-07-2018, 02:15 PM
              11 responses
              1,779 views
              0 likes
              Last Post aligator  
              Working...
              X