Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am looking for some cheap continuous ES Depth of Market (level II) data along with level I to use in a program I wrote. This kind of data is pretty expensive but Ninjatrader has some cheap options like MarketReplay.net and marketreplaydata.net. Used marketreplaydata before and it seemed fine. This data however goes directly into ninja. I would love to know if there is a way to export that data out of ninja. Has anyone done this? Any ninja scripts people are willing to share? I need both L1 and L2.
Can you help answer these questions from other members on NexusFi?
Thanks I think I am missing a few things -- since I am not at all familiar with how to extend NT functionality. I looked at the nt doc for the OnMarketDepth and it looks to run real-time for strategies or indicators. So a few questions.
1) Would the code to do this run as an "Indicator" or a strategy or is there some other way to interface with NT to do the extract.
2) I am having trouble finding what class I would call to read a bunch of market replay files. Would using "File" work? Do you happen to know what object that would be?
3) Is there a similar call to OnMarketDepth but for Level I? Would this be OnBarUpdate?
You should run this as a strategy and within the strategy either create print statements to the output window or if you are serious programmer you can send the data somewhere... such as a SQL Server table, or a file. If you are starting out I would stick with just doing a print to the output window. Then you just open your output window and copy it from there.
I should mention this gets a little tricky because the way that you run your print will need to contain some sort of delimiter logic otherwise you just end up with everything running together in one giant cell with no logical way to split it into columns. Here is an example from something I am doing that sounds similar.
I declare a few variables earlier... so that is why you do see this, but MDEbidV for example will hold the last known update to the bid volume. I run this after my update, because i use some logic to catch if there has been any change in this variable. So this will only print new values. Otherwise you end up with tons and tons of duplicated extraneous data.
For level 1 data you want to use the OnMarketData event handler. Something like this.
I didn't put print statements in there, but you can easily just copy the idea from the level 2 code block i posted above and get your level 1 objects. You should separate your print statements with some sort of identifier so you can tell your level 1 prints from your level 2 prints if you try to run this on the same strategy, otherwise it will get confusing.
Also, as I am sure you are wondering, if you want to capture level 2 prices further out. (Resting volumes several price levels out in the DOM for example) you will need to add multiple levels to the code example I provided. For each of these you will just need to capture the applicable price level by doing GetCurrentBid() -.25 or GetCurrentAsk() + .25 (These will give you the first resting level out.) Then just increment by .25 to get each additional level. You would just replace each of these in the if statement (&& GetCurrentAsk() == marketDepthUpdate.Price) where it is looking for the mareketDepthUpdate.Price... You just tell it which price level it is updaing. .25, .5, .75, 1.25, etc. Just add this to your getcurrentbid, or getcurrentask statements.
A bit complex, but totally easy using the examples I provided.
Ian, I bow down to your generosity and knowledge. A very heartfelt 'thank you' . One small question though: How do you specify that you want this to run against Market replay data? Ideally I would like to run this code against a number of days held in market replay files. Do I need to replay each day in order for this code to run or is there some sort of calls I can make to read from files directly.
Thanks again so much.
!! Whoops nevermind. You said this was a strategy so I can just select backtest and give it a date range. Awesome. Ian thanks again!