Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Replay's Current Time, Time[0] isn't what I'm expecting

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

    Replay's Current Time, Time[0] isn't what I'm expecting

    On a 3 minute chart, I am building a Strategy that in part deals with playing a sound when some certain criteria is met. Once the criteria has triggered and I've heard the sound, I wish to postpone hearing the sound again for 10 seconds, and only if the criteria is still occurring (or has re-occurred). Since there is a different sound for each criterion, I must track each sound’s occurrence separately. No problem.

    I’m developing within OnBarUpdate(). I watch for each criterion to trigger, play the appropriate sound, then store the DateTime.Now in a DateTime array per that sound file. This way I can check how long it has been since the sound was played. No problem. Everything works as expected.

    Now I begin to Replay a simulation in Replay Mode. This is nice because it’s tick by tick instead of candle by candle. If I speed up Replay Mode to 2x, 10x, 100x, etc, my sound playing is skewed because the last played DateTime is seconds ago when in reality of the ticks being saved was perhaps minutes ago. Of course, DateTime.Now is the ACTUAL time NOW, not the tick time when it really occurred.

    So I begin working with Time[0] to retrieve the current time of the tick. But it seems to be the time of the Close[0] of the bar we’re in, and NOT the DateTime of the tick when it occurred.

    What should I be using to capture the Tick’s time during Replay for Strategy analysis? I seem to be stuck with the current DateTime.Now, but I know that this isn’t accurate and is skewed during fast replays.

    Brian1

    #2
    You cannot use DateTime.Now because that is C# for your system clock's time. This is not correlated to your Market Replay time in any fashion.

    What you will need to do is run your own timer function. Please see this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=5965

    Also, please see the BarTimer variable for another example of using a timer. Unfortunately this is on the verge of being unsupported by us because it is more advanced programming. You can find more help on this either on MSDN or try Googling it. Good luck.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh.
      "The BarTimer variable" you mention sounds like it is NinjaTrader specific, but I can't find any reference to it. Could you please post a link to the documentation.

      Thanks
      Dave

      Comment


        #4
        Sorry DaveS. This was a typo. I meant BarTimer indicator.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the reply Josh. looks like I can do what i want using the DateTime stuff.
          Dave

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          179 views
          0 likes
          Last Post jeronymite  
          Started by ghoul, Today, 06:02 PM
          0 responses
          7 views
          0 likes
          Last Post ghoul
          by ghoul
           
          Started by Barry Milan, Yesterday, 10:35 PM
          6 responses
          19 views
          0 likes
          Last Post Barry Milan  
          Started by DanielSanMartin, Yesterday, 02:37 PM
          2 responses
          13 views
          0 likes
          Last Post DanielSanMartin  
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          13 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X