ModifyPendingOrderAsync & ModifyPositionAsync parameters

Created at 01 Dec 2021, 21:51
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!
NC

ncel01

Joined 19.03.2020

ModifyPendingOrderAsync & ModifyPositionAsync parameters
01 Dec 2021, 21:51


Hello,

How to code ModifyPendingOrderAsync & ModifyPositionAsync if I only want to modify a single parameter?

For instance, in case I only want to modify the stop loss distance, what would be the equivalent to position.ModifyStopLossPrice in Async mode?

 

Thanks!


@ncel01
Replies

amusleh
02 Dec 2021, 08:52

Hi,

You can just pass the Position current parameters and provide new value only for those parameters that you want to change.

For ex:

        protected override void OnTick()
        {
            var position = Positions.First();

            var newStopLossValue = 1.23423;
            // Here I just modify the stop loss
            ModifyPositionAsync(position, newStopLossValue, position.TakeProfit);
        }

 


@amusleh

ncel01
02 Dec 2021, 13:29

RE:

Hi amusleh,

Thank you for your reply.

That's clear!

 

Regards

 

amusleh said:

Hi,

You can just pass the Position current parameters and provide new value only for those parameters that you want to change.

For ex:

        protected override void OnTick()
        {
            var position = Positions.First();

            var newStopLossValue = 1.23423;
            // Here I just modify the stop loss
            ModifyPositionAsync(position, newStopLossValue, position.TakeProfit);
        }

 

 


@ncel01