Collision between two instances of the same object.

I have a game in which you can make balls appear. The balls are called ‘ball’. I would like the balls to bounce off each other, rather than passing through each other. I tried putting ball is in collision with ball, move ball away from ball, but it doesn’t seem to work.

In pseudo code:
When ball collide set speed x of ball to speed x*-1

Same for y speed.