{"id":1614,"date":"2021-02-08T08:04:14","date_gmt":"2021-02-08T08:04:14","guid":{"rendered":"https:\/\/pjsmith.me.uk\/?p=1614"},"modified":"2023-02-12T08:29:39","modified_gmt":"2023-02-12T08:29:39","slug":"ninjatrader-8-cleanup-tool","status":"publish","type":"post","link":"https:\/\/pjsmith.me.uk\/index.php\/2021\/02\/ninjatrader-8-cleanup-tool\/","title":{"rendered":"Ninjatrader 8 Cleanup Tool"},"content":{"rendered":"\n<p>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&#8217; usual way to resolve this is &#8211; 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. <\/p>\n\n\n\n<p>What this does <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Removes orders, order updates, and executions older than X days from your database<\/li>\n\n\n\n<li>Optimises the database to recover disk space and performance<\/li>\n\n\n\n<li>Optionally removes the log and trace files<\/li>\n\n\n\n<li>Optionally removes the database cache<\/li>\n<\/ul>\n\n\n\n<p>Although I&#8217;d had to go through the &#8216;delete the database and start afresh&#8217; 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 \ud83d\ude42  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 &#8211;  regular maintenance is now a breeze.  A typical run looks like this<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB.png\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"495\" data-attachment-id=\"1615\" data-permalink=\"https:\/\/pjsmith.me.uk\/index.php\/2021\/02\/ninjatrader-8-cleanup-tool\/etsbqpowyaahxfb\/\" data-orig-file=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB.png\" data-orig-size=\"707,495\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"EtSbqpoWYAAHXfB\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB-300x210.png\" data-large-file=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB.png\" src=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB.png\" alt=\"\" class=\"wp-image-1615\" srcset=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB.png 707w, https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB-300x210.png 300w, https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB-600x420.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/a><\/figure>\n\n\n\n<p>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&#8217;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.<\/p>\n\n\n\n<p><strong>A WARNING <\/strong><br>THIS IS ENTIRELY UNSUPPORTED (BOTH BY ME, AND NINJATRADER). <br>YOU USE IT ENTIRELY AT YOUR OWN RISK.<br>It does back up your database prior to making any changes. You&#8217;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&#8217;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&#8217;m happy.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p><strong>Download<\/strong><br><div class=\"sdm_download_button_box_default\"><div class=\"sdm_download_link\"><a href=\"https:\/\/pjsmith.me.uk\/?sdm_process_download=1&download_id=2541\" class=\"sdm_download green\" title=\"Ninjatrader 8 cleanup tool\" >Download Now!<\/a><\/div><\/div>\n\n\n\n<p><strong>Requirements<\/strong><\/p>\n\n\n\n<p>Ninjatrader 8<\/p>\n\n\n\n<p><strong>Licensing<\/strong><\/p>\n\n\n\n<p>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 <a href=\"https:\/\/ko-fi.com\/pjsmith\">buy him a coffee<\/a>. Just 1 coffee ( you can buy more if you want! ) &#8211; Or, consider it a beer! That&#8217;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 <a href=\"https:\/\/pjsmith.me.uk\/index.php\/tag\/NinjaTrader\/\">some of my other Ninjatrader bits and pieces<\/a>.&nbsp; Remember, I&#8217;ve got to eat and keep the lights on too! Thanks for your support!<\/p>\n\n\n\n<p><strong>Updates<\/strong><\/p>\n\n\n\n<p>2023.02.12 fixed download link (again). Sorry!<\/p>\n\n\n\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1615,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[72,5,57],"tags":[44],"class_list":{"0":"post-1614","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-ninjatrader","8":"category-tech","9":"category-trading","10":"tag-ninjatrader"},"jetpack_featured_media_url":"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2021\/02\/EtSbqpoWYAAHXfB.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/1614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=1614"}],"version-history":[{"count":0,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/1614\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/media\/1615"}],"wp:attachment":[{"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=1614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=1614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}