I don't think there is a specific function within any cheat code setup on cheat carts themselves, flash carts or homebrew offerings.
Three main approaches are then that I would consider.
1) You port the code in question to assembly and have a random on-off there. If you can port the code to assembly then this is two steps more.
2) You make some kind of accumulator in the AR code. This way it shuffles on and off every so many frames or whatever. The game might also have a number that always counts up and you could have it turn on or off accordingly, or if you are lucky and there are two numbers you can do a if this is greater than this AND this value is odd then execute. I don't have a particularly good source of constant randomness on the DS -- some might try the microphone but eh.
3) Have turn on and turn off set to different button combos (possibly single button) that you will hit during play. Randomise these button combos a bit so you don't know what does what and add them as the cheats. Eventually you might figure out what does it for that game but you can always change for next time. It should be possible to have multiple buttons doing different things. You could even combine it with 2) in some manner to only turn on when a given number in the game is odd or even, greater than/less than a given number or something like that.
It occurred to me on the assembly porting option (that would be 1) in the list) I meant as an AR code, not the you find the sub that subtracts one from ammo count and change it to a mov or add or something. Seems you got that but write as though someone else might benefit from it and all that.
As for the other thing the appearance of randomness (might not even have to technically qualify as pseudorandom) is surely good enough for this purpose -- it is not like any encryption is needed. Or if you prefer find or make two (or three or four) values and then do something based upon those.