NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 08-19-2012, 09:51 PM   #1
dukeb
Senior Member
 
Join Date: Mar 2012
Posts: 102
Thanks: 29
Thanked 4 times in 4 posts
Default DateTime Comparisons

I am trying to debug a script. I want to check a specific bar on the strategy tester.
I will need the info for a specific date/time... see the red highlight below.
I cannot find this in the ref section.

protectedoverridevoid OnBarUpdate()
{
SMACurrent=SMA(BarsArray[
0],50)[0];
SMAPast=SMA(BarsArray[
0],50)[1];

//if SMACurrent>SMAPast consider this an up trend
if (SMACurrent > SMAPast) <<<< and DateTime of a bar = '8/15/2012 5:00:00 AM
{

objBarsAgoNumber.Set (Closes[
0][1]);
BarsAgoNumber = (HighestBar (objBarsAgoNumber,
30)+1);
HighValuePast=MAX(High,
30)[1];
HighValueCurrent=Closes[
0][0];
Thank you,
Duke
dukeb is offline  
Reply With Quote
Old 08-19-2012, 09:56 PM   #2
Radical
Senior Member
 
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
Default

Is this what you're looking for?

DateTime thatOneTime = new DateTime(2012, 8, 15, 5, 0, 0);
if (SMACurrent > SMAPast && Time[0] == thatOneTime)
{...}
Radical is offline  
Reply With Quote
The following user says thank you to Radical for this post:
Old 08-19-2012, 09:58 PM   #3
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,770
Thanks: 158
Thanked 562 times in 553 posts
Default

Duke,

You can obtain this information just by calling Time[0].

You'd wanna put this below your condition.

Code:
if (SMACurrent > SMAPast) <<<< and DateTime of a bar = '8/15/2012 5:00:00 AM
{
Print(Time[0]);
}
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 08-19-2012, 10:17 PM   #4
dukeb
Senior Member
 
Join Date: Mar 2012
Posts: 102
Thanks: 29
Thanked 4 times in 4 posts
Default

Thank you... It is exactly what I was looking for.
Duke
dukeb is offline  
Reply With Quote
Old 08-19-2012, 10:19 PM   #5
dukeb
Senior Member
 
Join Date: Mar 2012
Posts: 102
Thanks: 29
Thanked 4 times in 4 posts
Default

I need to process a certain bar at a given time. It needs to be a condition of getting thru the 'if' statement.
Thanks, Matthew...
dukeb 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
Logical Comparisons of BarArray and Time values Question Kel108 General Programming 5 08-09-2012 11:19 AM
Time Comparisons - Trade Exit Scarlett09 Strategy Development 1 07-31-2012 08:31 AM
Maximum Bars Look Back + Comparisons MicroTrends Version 7 Beta General Questions & Bug Reports 6 05-20-2010 05:55 PM
Data Service Provider Comparisons miker Connecting 1 03-25-2009 08:19 AM
Multiple time frame indicator comparisons radford0222 Strategy Analyzer 1 02-04-2009 03:39 PM


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