Partial close code/EA

 

Hi all,

Does anyone know of any code (or an existing trade manager EA) which will handle partial closing of trades in the following way?

Let's say you place a trade with 5 pips risk, when the trade is up by 15 pips (3 x initial_risk), I want to partially close enough of the trade to cover the initial 5 pip risk and leave the original stop loss where it was. In this example I would close 1/3rd of the trade and leave the rest of it to continue on as a 'free' trade with the original SL.

Thanks in advance.

Regards, Paul.

 
paul_hughes:

Hi all,

Does anyone know of any code (or an existing trade manager EA) which will handle partial closing of trades in the following way?

Let's say you place a trade with 5 pips risk, when the trade is up by 15 pips (3 x initial_risk), I want to partially close enough of the trade to cover the initial 5 pip risk and leave the original stop loss where it was. In this example I would close 1/3rd of the trade and leave the rest of it to continue on as a 'free' trade with the original SL.

Use OrderClose() and set the size of the position you wish to close in the 2nd parameter  double lots   . . . 
 
RaptorUK:
Use OrderClose() and set the size of the position you wish to close in the 2nd parameter  double lots   . . . 


Thanks Raptor,

I was thinking more in terms of calculating amounts to close by, detecting new trades and handling (ignoring) the already partially closed orders, etc. I can write it but didn't want to 're-invent the wheel' if it's already been done.

Cheers, Paul.

 
paul_hughes:


Thanks Raptor,

I was thinking more in terms of calculating amounts to close by, detecting new trades and handling (ignoring) the already partially closed orders, etc. I can write it but didn't want to 're-invent the wheel' if it's already been done.

I know  ;-)  but you learn so much more when you re-invent the wheel  ;-)
 
RaptorUK:
I know  ;-)  but you learn so much more when you re-invent the wheel  ;-)


Yep, you got that right.....  :-)

Reason: