Traders generally (almost always?) have at least a few guards to keep the bandits away. So long as you have guards, you won't get arrested.
I generally travel without troops as trader. You don't want to be engaged in combat all the time. You want to get from A to B as fast as possible. And never got robbed.
But my feature request: Just delete the open border treaty. Foreign nobles are welcome unless we declare that our borders as closed.