Change TakeProfit for opened Position

Created at 26 Mar 2018, 18:30
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!
AN

anton.kovalchuk

Joined 01.03.2016

Change TakeProfit for opened Position
26 Mar 2018, 18:30


Hi all,

 

I have not found the way to edit opened position, my cBot have to recalculate TakeProfit for opened Position according to an algorithm.

var position = Positions.Find("RSI", Symbol, tradeType);

How set new TakeProfit for this position?

Thank you. 


@anton.kovalchuk
Replies

anton.kovalchuk
26 Mar 2018, 23:48

The example exists in cAlgo confluence. 

var position = Positions.Find("myLabel", Symbol, TradeType.Buy);
if (position != null )
{
    double? stopLoss = Symbol.Ask- 10*Symbol.PipSize;
    double? takeProfit = Symbol.Ask + 10 * Symbol.PipSize;
    ModifyPosition(position, stopLoss,  takeProfit);
}

 

 


@anton.kovalchuk

PanagiotisCharalampous
27 Mar 2018, 09:21

Hi Anton,

Did you manage to use the example?

Best Regards,

Panagiotis


@PanagiotisCharalampous

anton.kovalchuk
27 Mar 2018, 09:43

Hi Panagiotis,

Yes, it works a great.

 

Thanks,

 


@anton.kovalchuk

firemyst
14 Aug 2019, 10:04

RE:

anton.kovalchuk said:

The example exists in cAlgo confluence. 

var position = Positions.Find("myLabel", Symbol, TradeType.Buy);
if (position != null )
{
    double? stopLoss = Symbol.Ask- 10*Symbol.PipSize;
    double? takeProfit = Symbol.Ask + 10 * Symbol.PipSize;
    ModifyPosition(position, stopLoss,  takeProfit);
}

 

 

Shouldn't the above example be:

var position = Positions.Find("myLabel", Symbol, TradeType.Buy);
if (position != null )
{
    double? stopLoss = Symbol.Ask- 10*Symbol.PipValue; // use PipValue instead of PipSize because we are subtracting from price
    double? takeProfit = Symbol.Ask + 10 * Symbol.PipValue; //use PipValue instead of PipSize becacuse we are adding to a price
    ModifyPosition(position, stopLoss,  takeProfit);
}

because it's working in prices, not sizes?


@firemyst

PanagiotisCharalampous
14 Aug 2019, 10:13

Hi FireMyst,

No. PipValue shows the value of a pip in your balance currency. PipSize is related to the quoted asset.

Best Regards,

Panagiotis


@PanagiotisCharalampous