I doubt it was the trades which got you caught. Plus, if they were looking for trades, wouldn't they look for more ridiculous amounts being transferred? Like from major goldfarmers, not just 2m.
Tracking all the trades on Runescape would be a massive task to do, especially on both RS3 and OS. Think about the amount of data there.
It's more likely that they tracked the IP's on the those account's and were able to link them together like that. If one of those bots got flagged for using the client, then it wouldn't be difficult after that to link it to all your other accounts when you go to transfer money or logs around.