![]() |
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
|
|||||||
| Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
|
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 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Feb 2006
Location: London U.K.
Posts: 152
Thanks: 3
Thanked 2 times in 2 posts
|
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 |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Sorry DaveS. This was a typo. I meant BarTimer indicator.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Feb 2006
Location: London U.K.
Posts: 152
Thanks: 3
Thanked 2 times in 2 posts
|
Thanks for the reply Josh. looks like I can do what i want using the DateTime stuff.
Dave |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |