NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Reply
 
Thread Tools Display Modes
Old 12-16-2008, 02:30 PM   #1
Brian1
Member
 
Join Date: Feb 2008
Location: Overland Park, KS
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to Brian1
Default 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
Brian1 is offline  
Reply With Quote
Old 12-16-2008, 02:46 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-19-2009, 12:35 PM   #3
DaveS
Senior Member
 
Join Date: Feb 2006
Location: London U.K.
Posts: 152
Thanks: 3
Thanked 2 times in 2 posts
Default

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
DaveS is offline  
Reply With Quote
Old 02-19-2009, 02:02 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Sorry DaveS. This was a typo. I meant BarTimer indicator.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-19-2009, 02:09 PM   #5
DaveS
Senior Member
 
Join Date: Feb 2006
Location: London U.K.
Posts: 152
Thanks: 3
Thanked 2 times in 2 posts
Default

Thanks for the reply Josh. looks like I can do what i want using the DateTime stuff.
Dave
DaveS is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare bar time to session end time GuyFB Miscellaneous Support 7 08-11-2010 09:11 AM
bar time vs. trade time? greentrader Miscellaneous Support 4 07-28-2008 01:38 AM
Current bar ticks/time gone/left cherriman Indicator Development 2 04-20-2008 01:42 PM
Market Time and my Time! Agamenon Strategy Development 1 12-10-2007 09:29 AM
Dynamic base pointer or time reference for secondary time interval ct Strategy Development 11 06-20-2007 02:27 PM


All times are GMT -6. The time now is 02:02 PM.