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 > Indicator Development

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

Reply
 
Thread Tools Display Modes
Old 01-31-2012, 03:27 PM   #1
jkmott59
Member
 
Join Date: Jan 2012
Posts: 47
Thanks: 26
Thanked 0 times in 0 posts
Default Calculate On Bar Close/Open-Low-High-Close relationship

Hi all,

If 'Calculate on bar close' if False are the values of Open[0], Close[0], High[0] and Low[0] modified with each tick before OnBarUpdate gets called?

I'm guessing the answer is yes but want to confirm.

john
jkmott59 is offline  
Reply With Quote
Old 01-31-2012, 03:36 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi John,

Thanks for the post. The standard Open ,High, Low, Close values for your bars would be considered price data, so they will update independent of CalculateOnBarClose settings. There isn't available a COBC setting for standard price bars.

If you use Open[0], Close[0], etc in a script, then their values will update according to the scripts' CalculateOnBarClose settings. If CalculateOnBarClose = false, then OnBarUpate() will be raised with each tick. If COBC = true, then OnBarUpdate() is raised only on bar close.
NinjaTrader_RyanM is offline  
Reply With Quote
The following user says thank you to NinjaTrader_RyanM for this post:
Old 01-31-2012, 04:29 PM   #3
jkmott59
Member
 
Join Date: Jan 2012
Posts: 47
Thanks: 26
Thanked 0 times in 0 posts
Default

Thank you for your response. I didn't ask the question well. I understand that onbarupdate is called differently based on the CalculateOnBarClose setting.

The scenario I was exploring was if CalculateOnBarClose is false and OnBarUpdate is called with each tick. In that scenario are High[0] and Low[0] updated by the platform with each tick or is High[0] only set at the end of the time frame? I want to be absolutely sure.

john
jkmott59 is offline  
Reply With Quote
Old 02-01-2012, 03:48 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 John, they would be updated with each tick as well, so as new Highs and Lows are seen. With CalculateOnBarClose set to 'false' index 0 always means the currently developing / updating bar. With CalculateOnBarClose set to 'true' index 0 means the last completed bar.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-13-2012, 04:29 PM   #5
adam_norsworthy
Junior Member
 
Join Date: Feb 2012
Location: Canary Islands
Posts: 16
Thanks: 2
Thanked 0 times in 0 posts
Default

Hi Ryan,

On historical testing I understand the setting 'calculate on bar close' = false is irrelevant as it is always calculated as 'calculate on bar close' = true.

I have a strategy that enters a limit order 3 pips lower than the high of the last bar. What I would like the strategy to do is that:

"IF two bars have passed since the limit order was placed and the limit order is not filled, cancel the limit order". I have done this for historical testing by assigning an integer variable (called 'barcount') thats adds 1 to itself each time OnBarUpdate is called, and when 'barcount' = 3 then do not resubmit the limit order. This works on historical testing because OnBarUpdate is called on each bar for historical testing ('calculate on bar close' = true).

So...my question is how do I achieve the same thing for live testing when 'Calculate on bar close' = false, as each OnBarUpdate will calculate on each tick.?

Many thanks.
adam_norsworthy is offline  
Reply With Quote
Old 03-14-2012, 07:04 AM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi adam_norsworthy,
You can check when property FirstTickOfBar == true which is only once per bar. A sample showing best way to combine bar close/every tick logic is available here:
http://www.ninjatrader.com/support/f...ad.php?t=19387
NinjaTrader_RyanM is offline  
Reply With Quote
The following user says thank you to NinjaTrader_RyanM for this post:
Old 04-10-2012, 10:47 AM   #7
adam_norsworthy
Junior Member
 
Join Date: Feb 2012
Location: Canary Islands
Posts: 16
Thanks: 2
Thanked 0 times in 0 posts
Default

Perfect. Thanks Ryan.
adam_norsworthy 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
Is there a data structure that holds Close,Open,Low, High of a bar? freewind General Programming 5 02-27-2011 08:24 PM
How can I get the High, Low, Open, Close from BarsArray? atrader General Programming 2 04-24-2009 08:47 AM
Charting high/low/close and open/close widths gluebunny Charting 11 09-29-2008 10:47 AM
Plotting Open, High, Low, and Close. strategy1 General Programming 1 07-22-2008 03:20 PM
Trouble with Open, High, Low, Close SuzyG Indicator Development 4 03-05-2007 04:03 AM


All times are GMT -6. The time now is 12:00 PM.