Skip to main content

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.

6 Comments

  • asraghu says:

    Thanks

  • Anand says:

    Paul, another great goodies from your side! Damn it why did i find your site before!

  • Ivan Maesepp says:

    Hi Paul,

    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?

  • Ivan Maesepp says:

    Hi Paul,

    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.

Leave a Reply to Ivan Maesepp Cancel Reply

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