Its a sign of Iman that you feel ashamed after doing it. Dont lose hope and become hopeless.
Allah says his rahmat is greater than his anger. Allah will forgive you no matter what sin you but you have to repent it with your whole heart and should have a tear of nidamat(shame).
when you comit the sin, you repent and with all due ahad you repent that you wont comit it again but gradualy as time passes you comit it again. It is because when you comit the sin you feel bad and gets closer to Allah and ask for his forgiveness. Try not to lose connection with Allah.
Ask Allah that Allah I am weak you become my power and make me distant from shaytan.
Try to find Alternative, sex is basic need of life, and in young age it will arouse, if you are unmarried then get married.
whenever negative thought come in ur mind at that time imagine the after effect, masterbation will last only some minute but they feeling of curse will haunt you so i will stay back... i will have this pleasur for some time and then again i am going to curse myself why i did.... am i not the owner of my self..... talk to your self.....and say i will defeat my nafs... i will defeat shaytan....and seek Allah's mercy...recite aauzu billahi minasshaytanir razeem...
The moment these thought come in ur mind..just leav evithing and try to socialize with peopl....ur family member...and remember Allah is watching you.
Ask Allah for to help you, he will definately help you.