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 – 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 noticibly 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.

A WARNING
THIS IS ENTIRELY UNSUPPORTED (BOTH BY ME, AND NINJATRADER).
YOU USE 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 it’s thing and clear 100’s or even gigabytes of data from your store? (the latter is not uncommon!). Let me know. Cheers.

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.