You don't have to be good in order to have a guardian angel, He is the gift of God to you so that you will always receive a message from God telling you His will.
The guardian angel is the constant companion given to every soul, for the purpose of his advice and guidance. He will help you so many times and you won't even know it. But He will defend you from the attacks of the evil one.
20 I am going to send an angel in front of you, to guard you on the way and to bring you to the place that I have prepared.
21 Be attentive to him and listen to his voice; do not rebel against him, for he will not pardon your transgression; for my name is in him.
22 But if you listen attentively to his voice and do all that I say, then I will be an enemy to your enemies and a foe to your foes. (NRSV)
To my guardian Angel Prayer
Angel of God, my guardian dear, to whom God's love commits me here, ever this day, be at my side, to light and guard, rule and guide.
St. Gertrude's Guardian Angel Prayer
O most holy angel of God, appointed by God to be my guardian, I give you thanks for all the benefits which you have ever bestowed on me in body and in soul. I praise and glorify you that you condescended to assist me with such patient fidelity, and to defend me against all the assaults of my enemies. Blessed be the hour in which you were assigned me for my guardian, my defender and my patron. In acknowledgement and return for all your loving ministries to me, I offer you the infinitely precious and noble heart of Jesus, and firmly purpose to obey you henceforward, and most faithfully to serve my God. Amen.
The Work of God Apostolate