Ninjatrader has a database of files it maintains. These store every single trade, order update, charts and database cache, etc. As some users will have found, after a while, these can start to cause performance issues, especially if you do playback runs with automated sim trading, etc. NinjaTraders’ usual way to resolve this is – Delete everything and start again. Hmmm. This is a little drastic and I wanted something to simply remove the rubbish, keep the good data that I needed, and keep my platform in tip-top condition. So, I wrote this.
What this does
- Removes orders, order updates, and executions older than X days from your database
- Optimises the database to recover disk space and performance
- Optionally removes the log and trace files
- Optionally removes the database cache
Although I’d had to go through the ‘delete the database and start afresh’ approach once before due to performance issues (at the guidance of NT support), I certainly did not want to do this again! The first time I ran this, keeping 180 days of trade data, it removed over 250 thousand trade records and took around 10 minutes. Performance was noticeably better afterwards when NT was doing DB operations. All good 🙂 I now run this every week as part of preventative maintenance. I just have a batch file on my desktop with the command line in it and both clear flags set – regular maintenance is now a breeze. A typical run looks like this
All you need to do is extract the download to a folder and run the .exe per the above image from the command line. Instructions for usage will be shown, but it’s just a case of supplying the path to your Ninjatrader data folder along with the number of days of data you wish to keep, plus either or both of the 2 optional flags if you want.
THIS IS ENTIRELY UNSUPPORTED (BOTH BY ME, AND NINJATRADER).
YOU USE IT ENTIRELY AT YOUR OWN RISK.
It does back up your database prior to making any changes. You’ll find it in the DB folder with the date/time tagged on the end, so in the worst case, it should just be a matter to rename the backup and you are back in business. I’ve had no issues and it does work perfectly fine for me. Ninjatrader support might freak at the idea, but given their software lacks the features to do this, and because the performance issues this utility addresses are common, I’m happy.
Did this utility do its thing and clear hundreds or even gigabytes of data from your store? (the latter is not uncommon!). Let me know. Cheers.
This software is coffee ware. It is free to download and use, but, if you find it useful, please consider using the link in the app or the link on the right of this page to show the author you care and buy him a coffee. Just 1 coffee ( you can buy more if you want! ) – Or, consider it a beer! That’s not a lot for the time it saved you, is it? Without support, the author will neither maintain this product nor make new ones available publicly. Please be sure to check out some of my other Ninjatrader bits and pieces. Remember, I’ve got to eat and keep the lights on too! Thanks for your support!
2023.02.12 fixed download link (again). Sorry!
Updated 2022.12.31 to support new DB type (SQLite) in the latest versions of Ninjatrader 8. Support for the old database is retained. If the util finds the old .sdf file, it will try and work with it. Please note that during a Ninjatrader upgrade, whilst your data is migrated to the new .sqlite db, the old database might still be in your db folder. It is suggested that once you have upgraded successfully, you remove (or backup and remove) that old .sdf file.
Paul, another great goodies from your side! Damn it why did i find your site before!
Thanks for the comment. Enjoy 🙂
I downloaded this and extracted it to a folder. I then ran the NT8DBCleanup.exe and nothing happened. I then ran it as administrator and it asked me if I wanted to make changes and I said yes. I then saw something flash in the background and nothing else. I was expecting to be asked where the DB was and the number of days data I wanted to keep. Neither of these options were presented.
Have I done the right thing or, what should I have done?
Did you look at any of the screenshot examples above?
I am not used to running command line stuff so, I apologise for my ignorance. I have tried several times to input the same as yours ( with the relevant changes according to my directories. I am obviously doing something wrong. I have extracted the zip folder to a directory as per this location: D:\Users\User\Documents\pjSmith
Can you please detail exactly what I should be putting into the command line at the prompt mark. The current command line prompt is showing: C:\Users\User>
What do Need to add after C:\Users\User>
Thanks in advance.
Hi, I clicked on the download link and Google says there are no files available to download. Seems like the link is broken.
Yes, sorry – Currently broken. I hope to fix soon