![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Oct 2009
Posts: 64
Thanks: 9
Thanked 5 times in 4 posts
|
Hello
1. I have a strategy that runs on range bars with COBC=true. When exactly is OnBarUpdate() called ? is it run on the first tick of the new bar, for the old bar ? 2. I need this strategy to run with COBC=false and get some info every tick, yet I do not want it to go through all the end of bar calculations. How do I do that programatically ? Should I use "FirstBarOfTick" and if true go through the end-of-bar-calculations, else go trough tick calculations ? Is there a better way ? 3. If I need this strategy to read OnMarketUpdate event, how can I programatically know if it is the start/end of a range bar ? The documentation for FirstTickOfBar says it is only available in OnBarUpdate(). Thanks |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello tickling,
1. COBC is called on the first tick of the new bar, which is also where the previous bar ended. 2. Yes, you have to calculate it at the FirstBarOfTick. Please refer to this sample code which demonstrates it further http://ninjatrader.com/support/forum...ad.php?t=19387 3. OnMarketData and OnBarUpdate runs on different threads. As such FirstBarOfTick cannot be accessed from OnMarket Data. Unfortunately there are no native methods in OnMarketData to obtain that information. Please let me know if I can assist you any further.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Joydeep for this post: |
|
|
|
#3 | |
|
Senior Member
|
Quote:
As the OnBarUpdate() and OnMarketData() events sequence is not guaranteed, it being asynchronous, with no lock, it will not be perfect, but it should be close enough. If you need microsecond accuracy, then you are probably on of those mega rich High Frequency Traders, so NT is not your cup 'o tea anyway.
|
|
|
|
|
|
The following user says thank you to koganam for this post: |
|
|
|
#4 |
|
Member
Join Date: Oct 2009
Posts: 64
Thanks: 9
Thanked 5 times in 4 posts
|
Thanks ! The "close enough" solution is probably good enough ... will give it a try.
No mega rich HFT here
|
|
|
|
|
The following user says thank you to tickling for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calculate On Bar Close/Open-Low-High-Close relationship | jkmott59 | Indicator Development | 6 | 04-10-2012 10:47 AM |
| Range bars, strategy and close on bar | coolmoss | General Programming | 5 | 03-05-2012 12:04 PM |
| RE: calculate the sum of a specified range of bars | Shawn | General Programming | 2 | 11-10-2011 02:21 PM |
| Calculate on bar close = false but only signal on close of bar | gyoung | Indicator Development | 3 | 10-26-2011 11:15 AM |
| Calculate on bar close | unclelou | Charting | 1 | 03-25-2009 05:43 PM |