Partial close orders then do trailing stop

 

Hi,

I've coded an algorithm that can enter multiple trades based on several signals from different indicators. I am now trying to figure out how to close half of my open positions when they've reached a target profit range and then add a trailing stop on the other half of those particular trades that have been closed.

Any ideas on how this can be done? The main issue I'm having is when it comes to writing a code that allows the EA to detect when an open order is the other half of a previously closed order.

Any advice will be much appreciated.

 
DeleJohnson: I've coded an algorithm that can enter multiple trades based on several signals from different indicators. I am now trying to figure out how to close half of my open positions when they've reached a target profit range and then add a trailing stop on the other half of those particular trades that have been closed. Any ideas on how this can be done? The main issue I'm having is when it comes to writing a code that allows the EA to detect when an open order is the other half of a previously closed order. Any advice will be much appreciated.
There are many examples in the CodeBase of different types of trailing stop EAs. Study them and apply them to your own code.
MQL5 Code Base
MQL5 Code Base
  • www.mql5.com
MQL5 Source Code Library for MetaTrader 5
 

DeleJohnson:

 The main issue I'm having is when it comes to writing a code that allows the EA to detect when an open order is the other half of a previously closed order.

A common method is to move the SL to break-even after the partial close. 

Reason: