Break even: take partial profit and set new TP
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 contractsvar newTP = ??? // how do I set new TP for 5 pips from current price?
ModifyPosition(position, roundedBreakEvenLevel, newTP);
}
firemyst
30 Apr 2022, 19:47
RE:
shaahin69 said:
double newTP = (position.TradeType == TradeType.Buy ? Symbol.Ask + (5 * Symbol.PipSize) : Symbol.Bid - (5 * Symbol.PipSize));
@firemyst