ModifyPendingOrder won't accept more than 2 arguments where I need no to change the 2nd but the 3rd and onwards.

Created at 20 Apr 2022, 15:16
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

AnthonyY

Joined 16.01.2022

ModifyPendingOrder won't accept more than 2 arguments where I need no to change the 2nd but the 3rd and onwards.
20 Apr 2022, 15:16


Hi!

Its a noob question but bugs me out! ModifyPendingOrder won't accept more than 2 arguments where I need not to change the 2nd but the 3rd and onwards.

I am trying to test the mechanics of pending orders and to modify one of the order's 3rd argument, stoploss, but vscode ends in error. "No overload for method 'ModifyPendingOrder' takes 3 arguments.

How can I pass more arguments?

Here is the code, inside  protected override void OnStart()

.....

if (0==0)

{

 var resultSellH4Base = PlaceLimitOrder(TradeType.Sell, Symbol.Name, rsk4B, TargetEntry1, "SellH4BaseToBuyBackUpAirDist", 0, H4BaseToBuyBackUpAirDist);
                var SellH4Base = resultSellH4Base.PendingOrder;
                SellH4BaseID = SellH4Base.Id;
                // Buy Limit Order for Buy D1Base To D1Base To Sell BackDow nAir Dist
                var resultBuyD1Base = PlaceLimitOrder(TradeType.Buy, Symbol.Name, rsk4B, TargetEntry2, "BuyD1BaseToSellBackDownAirDist", 0, D1BaseToSellBackDownAirDist);
                var BuyD1Base = resultBuyD1Base.PendingOrder;
                BuyD1BaseID = BuyD1Base.Id;
                // Sell Limit Order for Sell D1Target To Buy BackUp Air Dist
                var resultSellD1Target = PlaceLimitOrder(TradeType.Sell, Symbol.Name, rsk4B, TargetEntry3, "SellD1TargetToBuyBackUpAirDist", 0, H4BaseToBuyBackUpAirDist);
                var SellD1Target = resultSellD1Target.PendingOrder;
                SellD1TargetID = SellD1Target.Id;

                System.Threading.Thread.Sleep(2000);
                foreach (var order in PendingOrders)
                {
                    if (order.Label == "SellD1TargetToBuyBackUpAirDist")
                    {
                     
                        ModifyPendingOrder(order, positions, D1TargetToBuyBackUpAirDist);
                    }

}

 

Thank you in advance!


@AnthonyY
Replies

amusleh
21 Apr 2022, 10:58

Hi,

There are several overloads available for ModifyPendingOrder method, if you don't want to change something then you can pass it's current value:

            foreach (var order in PendingOrders)
            {
                if (order.Label == "SellD1TargetToBuyBackUpAirDist")
                {

                    ModifyPendingOrder(order, order.VolumeInUnits, newStopLossInPips, order.TakeProfitPips);
                    // You can also use the PendingOrder.ModifyXXX methods
                    // order.ModifyStopLossPips(newStopLossInPips);
                }
            }

@amusleh

AnthonyY
21 Apr 2022, 11:28

RE:

amusleh said:

Hi,

There are several overloads available for ModifyPendingOrder method, if you don't want to change something then you can pass it's current value:

            foreach (var order in PendingOrders)
            {
                if (order.Label == "SellD1TargetToBuyBackUpAirDist")
                {

                    ModifyPendingOrder(order, order.VolumeInUnits, newStopLossInPips, order.TakeProfitPips);
                    // You can also use the PendingOrder.ModifyXXX methods
                    // order.ModifyStopLossPips(newStopLossInPips);
                }
            }

Hi!

You are the best, I don't know why but now it works and figured more in the process thank you so much!

I suppose the same goes similarly with ModifyPosition, yeah?


@AnthonyY

amusleh
21 Apr 2022, 12:54

Hi,

Yes, there are similar methods for Positions.

Please check the API references, there you will find all the overloads and samples.


@amusleh