NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-24-2012, 02:53 PM   #1
overflowing
Member
 
Join Date: Jul 2011
Posts: 38
Thanks: 12
Thanked 7 times in 4 posts
Default Does Bars refer to current Bars object in OnBarUpdate()?

What does the Bars property/field refer to?

Does it refer to the BarsArray[BarsInProgress] for the current call to OnBarUpdate()? That is, does BarsArray[BarsInProgress] == Bars? Can I substitute one for the other or do they refer to different objects?
overflowing is offline  
Reply With Quote
Old 07-24-2012, 03:05 PM   #2
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,858
Thanks: 162
Thanked 579 times in 570 posts
Default

Bars represents the data that is being processed by your script:

http://www.ninjatrader.com/support/h...s/nt7/bars.htm

These are used to find the BarsSinceSession, etc

BarsInProgress refers to the current call on OnBarUpdate related to the series that may be added, where BarsInProgress == 0 is the primary data series, and BarsInProgress == 1 would be an added data series.
NinjaTrader_Matthew is offline  
Reply With Quote
Old 07-24-2012, 03:10 PM   #3
overflowing
Member
 
Join Date: Jul 2011
Posts: 38
Thanks: 12
Thanked 7 times in 4 posts
Default

Quote:
Originally Posted by NinjaTrader_Matthew View Post
...where BarsInProgress == 0 is the primary data series, and BarsInProgress == 1 would be an added data series.
So that's my question, does the Bars property always refer to the primary data series? Or does it refer to the current data series that is being handled by OnBarUpdate()?
overflowing is offline  
Reply With Quote
Old 07-24-2012, 03:21 PM   #4
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,858
Thanks: 162
Thanked 579 times in 570 posts
Default

The Data Series that is being handled by OnBarUpdate

If you were to check Bars.x in OnBarUpdate, you would get multiple calls for each OBU call.

If you wanted to check for only one OBU call, you would need to check for Bars.x in a BIP filter:

Code:
		protected override void OnBarUpdate()
		{
			
			
			// This will be called twice as per each OBU call
			Print("BIP : " + Instrument.FullName + " | Bars  : " + Bars.BarsSinceSession);
		
			// These will be called only when that BIP is called
			if(BarsInProgress == 0)
			{
				Print("BIP 0 : " + Instrument.FullName + " | Bars  : " + Bars.BarsSinceSession);
			}
			
			if(BarsInProgress == 1)
			{
				Print("BIP 1 : " + Instrument.FullName + " | Bars  : " + Bars.BarsSinceSession);
			}
                  }
NinjaTrader_Matthew is offline  
Reply With Quote
Old 07-24-2012, 03:36 PM   #5
overflowing
Member
 
Join Date: Jul 2011
Posts: 38
Thanks: 12
Thanked 7 times in 4 posts
Default

So from within OnBarUpdate(), BarsArray[BarsInProgress] == Bars, no?
overflowing is offline  
Reply With Quote
Old 07-24-2012, 03:47 PM   #6
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,858
Thanks: 162
Thanked 579 times in 570 posts
Default

Yes, that would refer to the current data that is being processed in OBU()
NinjaTrader_Matthew is offline  
Reply With Quote
Reply

Tags
bars, barsarray, barsinprogress, onbarupdate

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
Triggering OnBarUpdate when their is no more bars freewind General Programming 3 12-19-2011 03:54 AM
Refer to manually made chart object Steven000 Market Analyzer 1 08-29-2010 11:42 AM
How to identify the last OnBarUpdate() call from history bars? 51friend Indicator Development 3 06-08-2010 08:10 AM
Conditional Bars Object for Indicators Ralph Version 7 Beta General Questions & Bug Reports 15 05-28-2010 11:47 AM
Bars object question The Kid Strategy Development 3 11-05-2008 11:09 AM


All times are GMT -6. The time now is 04:58 PM.