How can I set an opposite Pending order on the SL of a Position AND Automatically Cancel it, when the other Position hits a specific targetprice??

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Question is above, This is my Plan:
1 : ->Signal
2 : opening a Position (remembering its SL Level)
3 : setting an opposite pending order with x2 the initial lot size and 10 pips TP and finally setting SL Below/Above your initial trade SL + 5 pips
4 : if your initial trade hit the TP (or Trailingstop) then cancel the pending order (<-this is where I struggle)
I dont find an accurate way to do step 4.
I tried to get the ticket of the initial Position & the Pending (i hope this is right):
If this above is right I only need a way, how I can detect if the Initial order has been closed (wether by unchanged SL or by TP/Trailing stop or if it made a profit or a loss)
How can i get these Information of the closed Position???
Thank you so much ! :O