{"id":2800,"date":"2023-03-23T11:32:02","date_gmt":"2023-03-23T11:32:02","guid":{"rendered":"https:\/\/pjsmith.me.uk\/?p=2800"},"modified":"2023-03-23T11:32:05","modified_gmt":"2023-03-23T11:32:05","slug":"pjsunirenko-bars","status":"publish","type":"post","link":"https:\/\/pjsmith.me.uk\/index.php\/2023\/03\/pjsunirenko-bars\/","title":{"rendered":"PJSUniRenko bars"},"content":{"rendered":"\n<p><strong>PJSUniRenko bars<\/strong><br \/>Do we need another UniRenko indie!? Well, err, one that works. Yes! Here it is<\/p>\n\n\n\n<p>BTW &#8211; Please be sure to read down the post for why we needed this, especially if you have been using some of the versions available for public download.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"556\" data-attachment-id=\"2802\" data-permalink=\"https:\/\/pjsmith.me.uk\/index.php\/2023\/03\/pjsunirenko-bars\/ninjatrader_sfk0twxb4u_1\/\" data-orig-file=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1.webp\" data-orig-size=\"1176,638\" 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=\"NinjaTrader_SFK0TWxB4U_1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1-300x163.webp\" data-large-file=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1-1024x556.webp\" src=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1-1024x556.webp\" alt=\"\" class=\"wp-image-2802\" srcset=\"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1-1024x556.webp 1024w, https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1-300x163.webp 300w, https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1-768x417.webp 768w, https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1-600x326.webp 600w, https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_SFK0TWxB4U_1.webp 1176w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>So, why did we need this? Simply put, most of the versions that are in use are broken. Very broken! But, wait? How can they have been broken for all this time and nobody noticed!?  I used this slightly modified version for at least a couple of years and did not realise, so&#8230; I suspect there are at least 50,000 people using the broken versions. Yes, you read that right. 50k! Based on the download numbers I have seen.<\/p>\n\n\n\n<p>A little background. Anyone who has used the Ninjatrader 8 platform for a while has probably heard of other users talking about chart lag, or maybe experienced it themselves. The problem is that bars can be delayed in printing to the screen, especially during <strong>volatility <\/strong>(remember that part, it&#8217;s important!). Ninja themselves know about it. In fact, there are very common threads about it and pretty standardised support responses when someone asks about it. I see many people reporting it, <strong>especially with UniRenko bars. <\/strong>It&#8217;s a fact, people suffer from it, and we assume when someone reports all the symptoms, that&#8217;s what it is. I mean, if you are sneezing all the time, you probably have a cold or hay fever, right?  In this case, it&#8217;s not always so.  <\/p>\n\n\n\n<p>I had been suffering a few lags here and there during extreme volatility. This has always pretty much been the case. Now, I go to _extreme_ lengths to ensure my code is clean and performant. Eventually, I get to the stage where I decide, it was just a limitation of the NT8 platform. One of the contributing issues is that I trade small time frames and can have 4,000 bars on-screen on a single chart. Those all have to be re-drawn, etc., 5\/6 times a second on each chart, and, when you right and say, Hey, Ninja support, I have 6 screens, 24 charts, 80 indicators, and a gazillion bars, they will pretty much tell you the same. So, we accept it. BUT! &#8230;  I noticed a peculiarity one day. I was getting filled, in real-time, where the bars had not been printed. IF this were a real lag, the fill would be reported later too! Something does not add up here. I start to dig and after some investigation, I fire off an email to support re my suspicions. They ask me for a video. I send it. They tell me it is chart lag&#8230;<\/p>\n\n\n\n<p>Not convinced, or accepting their answer, I pull apart the code and finally find out what is going on after much investigation!  As many of you will already know. UniRenko bars (like Renko) are a fixed size. They print a new bar when the fixed size is exceeded. Now, here is where the problem was occurring. During volatility, you can get gaps and large moves where few if any trades will print. Price may actually exceed the size of a bar and this would mean you need to print as many bars as is needed to fill that gap. But, it does not! It will print 1 bar max for each price update. So, you get a 10 pt spike with zero liquidity during FOMC, and it will take the next 10 or 20 trades, or whatever, depending on your brick size, staying WITHIN that next few ticks of bar price range for the bars to actually catch up! LAG!  Or, apparent lag, anyways.  The solution, change the code to keep looping through bars until it has created enough bars to fill the gap on each single price change. Result &#8211; Instant amazement about how much different the PA was. Crisper, faster, cleaner! I am rather embarrassed I lived with this issue for so long!<\/p>\n\n\n\n<p>So, yes, I fixed it, and you can download it for free here. I recommend anyone using the standard UniRenko, especially if you download and used the one from the Ninjatrader Ecosystem, to use this instead. I have left it open source, so the authors of broken versions can see the code changes. At last look, the newest version of the one on the Ecosystem (the buggy one) had been downloaded over 15,000 times, so there are a lot of broken versions out there!<\/p>\n\n\n\n<p>So, there you go. I have no idea how many people have been suffering from &#8216;chart lag&#8217;, and just accepting it, or migrating to other platforms, when all the time, it was this issue that no one had noticed. I am glad to have found the issue, and happy to share the solution with the community. Good trades my friends.<\/p>\n\n\n<p><strong>Download<\/strong><\/p>\n<div class=\"sdm_download_button_box_default\"><div class=\"sdm_download_link\"><a href=\"https:\/\/pjsmith.me.uk\/?sdm_process_download=1&download_id=2805\" class=\"sdm_download green\" title=\"pjsUniRenko\" >Download Now!<\/a><\/div><\/div>\n<p>If you run into any issues installing this bar type, you might need to uninstall the old Unirenko type first. I intentionally kept the same bar type ID number, as this is a direct replacement, not a new bar type.<\/p>\n<p><strong>Updates<\/strong><\/p>\n<p>Please see the release notes in the <a href=\"https:\/\/pjsmith.me.uk\/index.php\/docs\/\">documentation<\/a> for details of updates<\/p>\n<p><strong>Requirements<\/strong><\/p>\n<p><!-- \/wp:post-content --><\/p>\n<p><!-- wp:paragraph -->Ninjatrader 8<\/p>\n<p><!-- \/wp:paragraph --><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><strong>Licensing<\/strong><\/p>\n<p><!-- \/wp:paragraph --><\/p>\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>.\u00a0 Remember, I&#8217;ve got to eat and keep the lights on too! Thanks for your support!<\/p>","protected":false},"excerpt":{"rendered":"<p>A fixed version of the popular UniRenko bar type for ninjatrader 8<\/p>\n","protected":false},"author":1,"featured_media":2803,"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":[],"class_list":{"0":"post-2800","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-ninjatrader","8":"category-tech","9":"category-trading"},"jetpack_featured_media_url":"https:\/\/pjsmith.me.uk\/wp-content\/uploads\/2023\/03\/NinjaTrader_AVmyFjn8SB_1.webp","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\/2800","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=2800"}],"version-history":[{"count":0,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/2800\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/media\/2803"}],"wp:attachment":[{"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=2800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=2800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pjsmith.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=2800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}