![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Nov 2008
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
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];
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2008
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
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] Code:
Opens[1][1]
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |