Stop Loss vs Close Order

 

So, I am being really new to trading and MT4.

I am trying to build a bot that would create 2 orders, but close one when the other is closed by TP/SL.

Is there any way for me to manage the closing of one order after the TP/SL has kicked in for the other order, or I have to manually check tick data and issue Close Order for both in the code?

Hopefully my explanation make sense. Thank you.

 
Since you are new to trading and MT4, I would suggest switching to MT5. It is the current version.

Nether the less to answer your question:

You query your trade history from within a script or ea to check for changes and if you find a SL/TP order, you take action on what to do now...

This is done differently in MT4 compared to MT5, but it can be done in both languages.
 
ffleader1:

So, I am being really new to trading and MT4.

I am trying to build a bot that would create 2 orders, but close one when the other is closed by TP/SL.

Is there any way for me to manage the closing of one order after the TP/SL has kicked in for the other order, or I have to manually check tick data and issue Close Order for both in the code?

Hopefully my explanation make sense. Thank you.

If PendingOrders()>0 and marketOrders()==0,Close PendingOrders()

You can do it with a function like