![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Oct 2009
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
Is there a anyway to know if when OnBarUpdate is called it is from live data or historical data?
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
PDT,
Yes! This is called "Historical" and is a variable. http://www.ninjatrader.com/support/h...historical.htm Please feel free to ask us questions any time, we are happy to answer.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2009
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Adam,
Thanks for the prompt reply. I am creating an indicator that loads a second instrument with a different timeframe. Everything works great on live real time data but if the chart is reloaded and for all previous sessions it looks like the data is exactly one bar off (before) from the charts instrument. Any thoughts on why? Thanks, Dan |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
PDT,
I am not sure here, could you possible post your code and/or some screen shots? http://take-a-screenshot.org/
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Oct 2009
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Adam,
I have spent some time trying to figure out what is going on and it looks like when the main instrument is loading historical data on the chart it is only calling OnBarUpdate once at the bar close. I am using a 2000 tick chart. I used the BarsInProgress == 0 and printed every time that OnBarUpdate was called and the times matched the ending times of that bar. 9/5/2012 8:29:59 AM 9/5/2012 8:30:45 AM 9/5/2012 8:32:11 AM 9/5/2012 8:33:58 AM 9/5/2012 8:35:52 AM etc. This is on the ES so there are lots of ticks going off in between. Can you explain how the historical data is processed. I assumed that it would call OnBarUpdate for each tick or change. Thanks, Dan |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Oct 2009
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
I do have CalculateOnBarClose set to False.
|
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
Hi Dan, for historical processing it would not matter how CalculateOnBarClose is set - it would be 'true' per default here, as the OnBarUpdate() is called for each completed bar, not for each tick (as it would be in realtime / market replay with the CalculateOnBarClose = false).
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Oct 2009
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Adam,
I am collecting data from the second intrument on a different time frame and putting it in a dataseries which matches the main instrument. With real time it works great but since the OnBarUpdate is only called at the end of the bar on Historical data the data I collected is put into the bar before when the new bar is created. I assume the dataseries are added to as each new bar is created. When OnBarUpdate is called for the current bar has the next bar been added to the dataseries? Is there a way to shift the data or an easy way add it to the next bar? Thanks, Dan |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Oct 2009
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Adam,
I just setup a second dataseries and handled the loading of the historical data differently so it is working fine now. Thanks, Dan |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OnBarUpdate | cshep | Version 7 Beta General Questions & Bug Reports | 2 | 08-18-2010 04:28 PM |
| OnBarUpdate | eqtrader | General Programming | 5 | 07-28-2010 10:37 AM |
| OnBarUpdate() | Rhyshaelkan | General Programming | 0 | 01-09-2010 03:11 PM |
| Twice through OnBarUpdate()? | cybertunerone | Strategy Development | 4 | 02-08-2009 01:52 AM |
| OnBarUpdate | SystemTrading | Miscellaneous Support | 3 | 08-20-2008 10:38 AM |