close order by Id? or select?

Created at 30 Nov 2015, 22:38
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!
IU

iulik2k1

Joined 16.08.2013

close order by Id? or select?
30 Nov 2015, 22:38


Hi there..

after i try to find the loosest order i wanna close:

 

         private double badtrade()
        {
            double loose = 0;
            if (Positions.Count > 0)
            {
                for (int i = Positions.Count - 1; i >= 0; i--)
                {
                    position = Positions[i];
                    if (position.NetProfit < loose && position.SymbolCode == Symbol.Code)
                    {
                        loose = position.NetProfit;
                        //orderid = position.Id;  //try to close order by Id?

                        //modifyposition("... try to put a label after that? and close by label?

                    }
                }
            }


            return (loose);
        }

 

any help?


@iulik2k1
Replies

mindbreaker
01 Dec 2015, 10:05

RE:

iulik2k1 said:

Hi there..

after i try to find the loosest order i wanna close:

 

         private double badtrade()
        {
            double loose = 0;
            if (Positions.Count > 0)
            {
                for (int i = Positions.Count - 1; i >= 0; i--)
                {
                    position = Positions[i];
                    if (position.NetProfit < loose && position.SymbolCode == Symbol.Code)
                    {
                        loose = position.NetProfit;
                        //orderid = position.Id;  //try to close order by Id?

                        //modifyposition("... try to put a label after that? and close by label?

                    }
                }
            }


            return (loose);
        }

 

any help?

/api/guides/trading_api#el5


@mindbreaker

iulik2k1
01 Dec 2015, 15:36

thanks for the rtfm :D i'm a beginner:

i wanna mark an order after is open. i can't change order info after is created, with modifyposition i can't alter label or comment.

solution is to create unique serial label, and select that order with Positions.Find(order_unique_label)

thanks.

 


@iulik2k1