Congratulations on the level of insight you have achieved. That's half the battle. To admit you both want him to stay away and want him to come back helps you see your own inner conflict and that is the first, hardest step in resolving it.
If your ego is anything like mine, it can be a mix of both good and bad intentions. And, there is more to you than your ego.
There is a place in all of us that when we are calm and centered knows what is best. Unfortunately, the insecure voice is always pretty loud and insistent.
What might you do to cultivate the quiet inner voice that knows what is best for you (whatever that is). And if that voice says stay away, what does it say about how to support yourself in that.
Insecurity about identity, purpose, the future, etc., can seep into any one of us.
Consciously seeking out goals that are important to you and finding a purpose that taps into your motivation is a great way to put your ex-bf into perspective.
If you can ease your insecurity through your own accomplishments, it might not completely calm your ego, but you might be looking for higher quality "strokes" than the "begging to get you back" kind.
Wishing you clarity and peace,