Andrew Smith is a 3rd-degree BJJ black belt based out of Richmond, VA (Revolution BJJ). He runs BJJ Path, a video tutorial website.
The "ninja roll" is an advanced and crafty back take maneuver designed to perplex and mystify your opponent. If it's done correctly, especially with a lockdown of the legs and step-by-step as previously described here, it's extremely hard to stop. So... what can you do if someone goes for this move on you? Obviously, the first step in countering is understanding what your partner is up to, and what their objectives are each step of the way. If you've studied the previous ninja roll tutorial, you know that getting your leg perpendicular to your partner's is crucial to executing a proper back take or calf slicer, so you can certainly disrupt that, but let's look at exactly how this can be done in the moment.
Simple Solution and First Option
Early Stage Defense
The easiest way and most likely scenario for your partner to go for this move is when you're escaping from mount back to "quarter guard," typically on your way to transitioning to deep half guard. As soon as you capture your partner's foot and feel them tightening up and shifting their weight toward your back, you have a pretty good idea that a ninja roll is coming. The key here is fairly simple: don't hold on with your legs. Instead, release your leg triangle (where you're capturing the foot), and then shift your hips to the side so that your shin is perpendicular to their "knee pit," and not the other way around. Another way to think about this is to try to get your knee to the ground, but your foot in the air. If your partner opts to hold on and keep going to your back, you can, of course, take their back as an answer, but most likely, they're going to turn back in toward you, ending up in your half guard (and completing a solid guard recovery).
Two More Tips
Two additional details are going to help you to prevent your partner's establishing this position. First, be sure that you straighten your leg initially. If your partner is really good at establishing the lockdown, if your leg is bent at all (even if you understand that you need to hip out and try to get your knee to the ground), you're likely to be unsuccessful in preventing them from establishing the lockdown. Second, add in a solid stiff-arm with your hand that's on your partner's knee. This will further prevent their hip from turning in relation to yours, thus increasing your odds of pivoting successfully to create the desired angle.
And Now, the Counter
The above is an excellent defense to the back take, but in order to counter and successfully be able to take your opponent's back, assuming your opponent is savvy, you're going to have to assume that your partner will never keep rolling intentionally, ultimately giving up their own back, once they realize that you have superior leg positioning. The good news is that, when you're wearing the gi, you have a way to stop them from bailing out from the position. Reach for the far-side lapel, untuck it, and then staple it by lowering your forearm across their lower back. As your partner tries to bail out from the failed ninja roll and come up on top in half guard (as described previously), they'll find that your "gi staple" makes this impossible. Now it's up to you to finish the back take as usual, being careful to control your partner every step of the way as you advance up their body.
Keep on Truckin'
In order to get good at the defense, you most certainly must first be competent at the offense. If you understand how the basic ninja roll works, you can then proceed to the defense, and then, ultimately, to the counter shown here at the end. Remember that your partner is already pretty good if they're going for this move in the first place, so don't be surprised or frustrated if they're still able to get your back the first few times you try this. This isn't like a basic triangle, where you can set it up on any white belt, but instead a much more advanced "human chess" game.