![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: May 2007
Posts: 112
Thanks: 0
Thanked 0 times in 0 posts
|
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]; Same goes for not running an indicator unless X days of data are present ? Instead of Code:
if (CurrentBar < barsperday * period)
return;
|
|
|
|
|
|
#2 |
|
Senior Member
Join Date: May 2007
Posts: 112
Thanks: 0
Thanked 0 times in 0 posts
|
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). |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: May 2007
Posts: 112
Thanks: 0
Thanked 0 times in 0 posts
|
OK Second problem solved.
if (Bars.BarsSinceSession == 1) sessioncount++; if (sessioncount < period+2) return; |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Glad you figured it out.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |