Ninjatrader has a database of files it maintains. These store every single trade, order update, chart and database caches, 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 backup 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 tool is a freebie. Feel free to download it for your own personal use. Please be sure to check out some of my other Ninjatrader bits and pieces. If you wish to donate, please feel free to contribute towards further development. Remember, I’ve got to eat and keep the lights on too! Maybe buy me a coffee. Thanks for your support!