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 > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 02-01-2008, 06:50 PM   #1
scriabinop23
Senior Member
 
Join Date: May 2007
Posts: 112
Thanks: 0
Thanked 0 times in 0 posts
Default Best way to get priorclose from days previous to the previous

I am having trouble figuring the best way to find the priorclose 2, 3+ days ago...

The closest I can get (no cigar, not accurate) is this:

Code:
int barsperday = 1440 / Bars.Period.Value;
closeratio = PriorDayOHLC().PriorClose[(i-1)*barsperday]/PriorDayOHLC().PriorClose[i*barsperday];
But obviously no contracts actually trade the entire 24 hrs (and thus have 1440 minutes of bars). So any idea how to get priordayohlc in *session* terms instead of *bar* terms?

Same goes for not running an indicator unless X days of data are present ? Instead of
Code:
 
if (CurrentBar < barsperday * period)
    return;
What is recommended?
scriabinop23 is offline  
Reply With Quote
Old 02-01-2008, 08:21 PM   #2
scriabinop23
Senior Member
 
Join Date: May 2007
Posts: 112
Thanks: 0
Thanked 0 times in 0 posts
Default

ok figured this out by myself...

This does the job. BTW, is bars.getsessionbar(0) the close of the last session or the current session?

closeratio = Bars.GetSessionBar(i).Close/Bars.GetSessionBar(i+
1).Close;

Now I need to figure out how to have the indicator return if I don't have enough data (ie it needs i days of data minimum).
scriabinop23 is offline  
Reply With Quote
Old 02-01-2008, 08:49 PM   #3
scriabinop23
Senior Member
 
Join Date: May 2007
Posts: 112
Thanks: 0
Thanked 0 times in 0 posts
Default

OK Second problem solved.

if (Bars.BarsSinceSession == 1)
sessioncount++;
if (sessioncount < period+2)
return;
scriabinop23 is offline  
Reply With Quote
Old 02-02-2008, 12:41 AM   #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

Glad you figured it out.
NinjaTrader_Josh 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
Current Bid > High of Previous 20 Days davidfw1866 Strategy Development 2 11-27-2007 06:08 AM
Ninja log from previous day geoarb Miscellaneous Support 1 08-16-2007 01:40 AM
Referencing Previous Instance(s) Of Condition roxana Automated Trading 11 08-01-2007 05:13 PM
CrossBelow previous bar and omit current bar ct General Programming 1 06-03-2007 02:54 AM
Reloading a previous sim chart Antraman Miscellaneous Support 7 12-27-2005 03:51 AM


All times are GMT -6. The time now is 11:43 AM.