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 04-14-2008, 04:49 AM   #1
skynetman
Senior Member
 
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Post Get Opening market price

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
skynetman is offline  
Reply With Quote
Old 04-14-2008, 05:05 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

GetBar returns the absolute index of a bar and not the "barsAgo" index which you would need to stuff into Close[barsAgo].
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-14-2008, 08:22 AM   #3
skynetman
Senior Member
 
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Default

So what can i use with getbar to have the price?
skynetman is offline  
Reply With Quote
Old 04-14-2008, 08:25 AM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

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
NinjaTrader_Dierk 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
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


All times are GMT -6. The time now is 06:13 AM.