Break even: take partial profit and set new TP

Created at 30 Apr 2022, 02:13
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
SH

shaahin69

Joined 28.01.2022

Break even: take partial profit and set new TP
30 Apr 2022, 02:13


Hi, 

 

I am trying to implement break even when order is in profit. 

Say if I have positions open with 15 contracts, I wish to close 10 contracts only once position pips is greater than 2 and move the SL to break even. Then I want to specify a new TP for the amount of 5 pips.

I have found an example related to break even in cTrader cBot examples, however, I am still unsure how to take profit partially as well as setting a new TP.

Is following correct? 

 

var TP = 2;

if (position.Pips > TP)

{
ClosePosition(position, 10); // close 10 contracts 

var newTP = ??? // how do I set new TP for 5 pips from current price?

ModifyPosition(position, roundedBreakEvenLevel, newTP);

}


@shaahin69
Replies

firemyst
30 Apr 2022, 19:47

RE:

shaahin69 said:

Hi, 

 

I am trying to implement break even when order is in profit. 

Say if I have positions open with 15 contracts, I wish to close 10 contracts only once position pips is greater than 2 and move the SL to break even. Then I want to specify a new TP for the amount of 5 pips.

I have found an example related to break even in cTrader cBot examples, however, I am still unsure how to take profit partially as well as setting a new TP.

Is following correct? 

 

var TP = 2;

if (position.Pips > TP)

{
ClosePosition(position, 10); // close 10 contracts 

var newTP = ??? // how do I set new TP for 5 pips from current price?

ModifyPosition(position, roundedBreakEvenLevel, newTP);

}

double newTP = (position.TradeType == TradeType.Buy ? Symbol.Ask + (5 * Symbol.PipSize) : Symbol.Bid - (5 * Symbol.PipSize));


@firemyst