NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM 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 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 11-05-2008, 09:11 AM   #1
The Kid
Junior Member
 
Join Date: Nov 2008
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
Default Bars object question

Hello,

Hello, I'm writing my first strategy and can't find in the reference guide the methods of the Bars object.

Perhaps someone out there can help me.
If I want to get the Open of a bar n barsago how would I do that?

myBars[barsago].Open doesn't compile saying that myBars[barsago] is a double.
If so what double is it? The Open, Close, High, Low, Volume?

Thanks so much
The Kid is offline  
Reply With Quote
Old 11-05-2008, 09:45 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi The Kid,

I would recommend reviewing this link and the associated tutorials first -

http://www.ninjatrader-support.com/H...verview18.html

Then,

to get the open price for example for 4 bars ago, you can simply write

Code:
 double myOpen = Open[4];
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 11-05-2008, 09:57 AM   #3
The Kid
Junior Member
 
Join Date: Nov 2008
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi there, I'm using more than one bar object in my strategy so calling Open on it's own will not be in the correct context for my secondary Bars

I have gone through the material in the link already, but don't see a solution there.

I have a feeling I am not using the correct Objet type.
Here's one of the things I am doing:

publicdouble sum(Bars x,int windowSize)
{
double theSum = 0;
int i;

if ( x.Count <= windowSize ){
for (i = 0;i < windowSize;i++){
theSum=theSum+ x[i];
}
}
return theSum;
}

I am calling this function as follows:

sum(BarsArray[1],2000);

I was expecting x to be of type Bars and to have Open, Close, High, Low and Volume members, but it doesn't seem to have any of that.

I don't see the Bars object explained in the help on the web. Quite possibly I am not looking in the right place. I guess I could resolve all this if you could point me to a comprehensive document with all objects and members explained.

Thanks so much
The Kid is offline  
Reply With Quote
Old 11-05-2008, 11:09 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi The Kid,

Thank you for your patience

Please review the two links here -

http://www.ninjatrader-support.com/H...BarSeries.html

http://www.ninjatrader-support.com/H...struments.html

To access the Close[0] of the first time series you can use -

Code:
 Closes[0][0]
To access the Open[1] of the second time series you can use -

Code:
 Opens[1][1]
NinjaTrader_Bertrand 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
bars required question woodside Strategy Development 3 07-15-2010 03:27 AM
Bars.GetSessionBar Comparison results in Object Reference error bani789 Strategy Development 2 06-12-2008 01:54 PM
Object not set to an instance of an object ATI user Historical NinjaTrader 6.5 Beta Threads 1 12-14-2007 03:35 AM
To use the MAX indicator for Bars Object other than [0], what is needed? dendy General Programming 2 11-15-2007 06:16 PM
Error: Object reference not set to an instance of an object. Januson Market Analyzer 1 05-18-2007 12:12 AM


All times are GMT -6. The time now is 09:03 PM.