![]() |
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: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
|
I want to get the price at a given time, in the example 11:30 (opening of the market ).
My code does not work.... private DataSeries myDataSeries; //in variables ..... myDataSeries = new DataSeries(this); //in initialize method ..... int BarsAgoOpenPrice = Bars.GetBar(new DateTime(2008,04,14,11,30,0,0)); OpenPrice = Close [BarsAgoOpenPrice]; Do i have also to check with myDataSeries.ContainsValue(BarsAgoOpenPrice) if there is a value? Thx
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
GetBar returns the absolute index of a bar and not the "barsAgo" index which you would need to stuff into Close[barsAgo].
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
|
So what can i use with getbar to have the price?
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
You need to apply some math to convert the absolute index to the barsAgo index like (pseudo code):
int barsAgo = CurrentBar - GetBar(new DateTime(2008,04,14,11,30,0,0)) http://www.ninjatrader-support.com/H...V6/GetBar.html
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Opening GAP Indicator to be used in MARKET ANALYZER | fragalles | Indicator Development | 14 | 01-26-2011 07:23 AM |
| The T&S window shows the daily close price in post market | Pete S | Historical NinjaTrader 6.5 Beta Threads | 4 | 03-19-2008 09:24 AM |
| Opening a TCP socket from NTS ? | Wessel | General Programming | 2 | 03-11-2008 04:33 AM |
| Opening NT | dgregor5 | Historical NinjaTrader 6.5 Beta Threads | 4 | 01-19-2008 03:08 PM |
| No Opening or Net Change in MA | higler | Market Analyzer | 2 | 05-09-2007 09:02 AM |