Let's say your Trainer Name is Bobby. K? Your ID is 234087.
Your Charmeleon reaches a level higher than your Gym Badge can, well, control. Will your Charmeleon, which OT is Bobby and has an ID of 234087, disobey YOU, the original trainer?
When a Pokémon is obtained in a trade, it oftentimes will not obey the player's commands if it is at too high a level and the player does not have the appropriate Badge or number of Badges. Having all eight Badges always makes all Pokémon obey the player. This rule stands to prevent players from trading in a high-leveled Pokémon trained on another game and easily beating the game.
So from what I understand the Pokemon has to be traded to disobey you. Hope I helped :)
Source: Bulbapedia