Exiting a position at different targets?

 
Hi,
I want to exit a position on a certain symbol in this way:

As soon as I enter it I want a profit target at +10 pips (i.e.) for half position.
When 1st target is reached I want to have stop loss at break even for le 1/2 of lots remained.

Then I want to put 1/2 of the remaining lots at +30 pips (i.e.) and when 2nd target is reached I want to trail the remaing lots (they are 1/4 of original lots) .

How can I manage this in MT4 code? I'm rather new in using this platform.

Thanks
Reason: