Stop Loss trigger for cancel current PendingOrder

v.fiodorov83 since: 24 Jul 2019;

  10 Sep 2021, 22:19
Stop Loss trigger for cancel current PendingOrder

Hello good people!

Please, help!

There is a task to open buy-stop orders at the initial one price.

One pending order at a specific price has been filled in the OnTick () Method.

How to make the logic in which the 2nd buy-stop order is not placed until the first one hits the stop-loss, only after that

amusleh's avatar

amusleh since: 01 Mar 2021;

  13 Sep 2021, 11:06

There are Filled, Modified, and Canceled events for PendingOrders you can use, and there are similar events of positions like Closed, Modified, and Opened.

Community Developer | Spotware | Telegram: @algodeveloper

v.fiodorov83 since: 24 Jul 2019;

  14 Sep 2021, 17:38
RE:

amusleh said:

There are Filled, Modified, and Canceled events for PendingOrders you can use, and there are similar events of positions like Closed, Modified, and Opened.

Thanks. Apparently I'll have to write a counter. If the buy-stop is full, then the counter will be 1, and a new buy-stop will open if the counter is 0

m4trader4 since: 19 Sep 2021;

  03 Oct 2021, 11:05
RE: RE:

v.fiodorov83 said:

amusleh said:

There are Filled, Modified, and Canceled events for PendingOrders you can use, and there are similar events of positions like Closed, Modified, and Opened.

Thanks. Apparently I'll have to write a counter. If the buy-stop is full, then the counter will be 1, and a new buy-stop will open if the counter is 0

I have cut and pasted my code Use the function and place the orders accordingly.

private int CheckPositions(TradeType TTtype)
        {
            var positionsCBO = Positions.FindAll("", Symbol.Name, TTtype);
            return (positionsCBO.Length);
        }


=============================================================

 if (CheckPositions(TradeType.Sell) == 0)
                        {
                           // Place order
                        }

 if (CheckPositions(TradeType.Buy) == 0)
                        {

// Place Order
                        }

emmasystems since: 08 Dec 2015;

  16 Oct 2021, 00:02
RE:

amusleh said:

There are Filled, Modified, and Canceled events for PendingOrders you can use, and there are similar events of positions like Closed, Modified, and Opened.

Please , how are Pending orders placed in ctrader code  like example , CreatePendingOrder, does that have to be used even modifying or setting Limit. Thanks

amusleh's avatar

amusleh since: 01 Mar 2021;

  18 Oct 2021, 08:57
RE: RE:

emmasystems said:

amusleh said:

There are Filled, Modified, and Canceled events for PendingOrders you can use, and there are similar events of positions like Closed, Modified, and Opened.

Please , how are Pending orders placed in ctrader code  like example , CreatePendingOrder, does that have to be used even modifying or setting Limit. Thanks

Hi,

You can find cBot examples for how to place/modify/cancel pending orders here: cAlgo API Reference - PendingOrder Interface (ctrader.com)

Community Developer | Spotware | Telegram: @algodeveloper