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 02-10-2009, 03:42 AM   #1
diffused
Member
 
Join Date: Oct 2008
Posts: 44
Thanks: 0
Thanked 0 times in 0 posts
Default enumerating each day DateTime in a chart

What is the best way to obtain a DateTime list of each unique day in a chart?

i would like to do something like this:

foreach(DateTime day in dayList)
{
// stuff
}



cheers
diffused is offline  
Reply With Quote
Old 02-10-2009, 04:06 AM   #2
Ralph
Senior Member
 
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
Default

Code:
for(int i = 0; i <= CurrentBar; i++)
  Print(i + ": " + Time[i]);
Ralph is offline  
Reply With Quote
Old 02-10-2009, 04:14 AM   #3
diffused
Member
 
Join Date: Oct 2008
Posts: 44
Thanks: 0
Thanked 0 times in 0 posts
Default

doesnt seem to work.

CurrentBar is -1

Quote:
Originally Posted by Ralph View Post
Code:
for(int i = 0; i <= CurrentBar; i++)
  Print(i + ": " + Time[i]);
diffused is offline  
Reply With Quote
Old 02-10-2009, 04:18 AM   #4
Ralph
Senior Member
 
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
Default

You need to place that code in OnBarUpdate() because it is the only place where you get valid values for CurrentBar.

Regards
Ralph
Ralph is offline  
Reply With Quote
Old 02-10-2009, 04:20 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Thanks for your help Ralph!
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-10-2009, 04:34 AM   #6
diffused
Member
 
Join Date: Oct 2008
Posts: 44
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by Ralph View Post
You need to place that code in OnBarUpdate() because it is the only place where you get valid values for CurrentBar.

Regards
Ralph
ah, cheers for that.
diffused 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
backtesting and DateTime.Now andrewbee Strategy Analyzer 3 06-28-2010 09:18 AM
DateTime as an Integer Error spinalwiz Strategy Development 2 11-18-2008 05:52 AM
DateTime.Now vs Market Replay ATI user Strategy Development 3 11-15-2008 07:35 PM
Possible to chart the first 30 min candle of day and that's it? brownsfan019 Charting 4 04-17-2008 11:36 AM
Forex Day chart only shows one bar atrader101 Connecting 4 03-07-2008 11:45 AM


All times are GMT -6. The time now is 10:47 AM.