![]() |
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: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
|
Hello,
I am using OnMarketDepth event to build a coherent Order Book. I am using the SampleMarketDepth template. My question is related to have coherent data in a particular Time. In order to have a coherent OrderBook several instructions need to be processed (for example a change on a price level needs a Remove instruction and an Insert instruction). If in the meantime of these instructions, I perform some calculations they would be wrong because they must be done after the second instruction. I know it is because race conditions but I wonder if there is any way to know if in a particular time data is coherent. Related to this problem, I want to know, what is the purpose of MarketDepth member of MarketDepthEventArgs class? It seems to have MarketDepthRowCollection items. Is it up to date? Is it valid? Can I use them to have a coherent real time Order Book? Thank you in advance |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello jbesada,
If you look into the SampleMarketDepth code, it uses the lock statement to make sure the collection is not modified until we finish the processing (of our custom calculation). Please refer here to know more about the lock statement http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx This is however more of a C# query and beyond what we could support. The MarketDepth object further exposes the various objects and collections of the level 2 data. Yes, it is realtime and updated on each change in the order book.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
|
Thank you for the answer but unfortunately it was not my question.
I know how to use lock and event conditions. Sorry if my explanation is not very clear. If for example a change on a price level arises, several OnMarketDepth events need to be processed in an atomic way (lets to say a remove and then an insert for example), but because you don't know how many events are needed, you can have a non coherent Order Book in the meantime of these events (a lock statement doesn't prevent this). To summarize, changes in the Order Book could need several events to be processed, is there any way to know how many events will come up to have a 'coherent' order book? Regards |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello jbesada,
OnMarketDepth is called and guaranteed to be in the correct sequence for every change in level II. However we have no way to know what data is coming. It is chaotic as it would and orders can get added/updated/deleted at any time. To know when it is coherent, one needs to have a reference point and also one needs to define what is "coherent". I look forward to assisting you further.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
![]() |
| Tags |
| level ii, order book |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| built-in order safeguards | boaza | Automated Trading | 9 | 12-20-2011 02:05 PM |
| ATM versus Built in order management | cashinvestor | Strategy Development | 5 | 09-06-2011 09:34 PM |
| Is the order book misleading? | tradingGary | SuperDOM and other Order Entry Windows | 1 | 05-06-2010 06:47 PM |
| How many lines in the book order? | pierrreg | Charting | 9 | 11-03-2009 10:27 AM |
| NinjaTrader not realeasing IB order book requests. | CraigC | Automated Trading | 1 | 07-01-2008 11:10 PM |