How to assign order to the specific trade?

Created at 05 Nov 2016, 08:04
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!
IR

iRobot

Joined 17.02.2013

How to assign order to the specific trade?
05 Nov 2016, 08:04


Let's say buy trade A is executed on EUR/USD at 1.12. Additional order B is placed to buy at 1.11. However, after some signal buy trade C is executed at 1.1140. Now I want order B to be canceled, and new buy order D placed at 1.1040. What's the code?

To put it in other words, how to assign specific order to specific trade?

Thanks


@iRobot
Replies

kricka
05 Nov 2016, 19:50

Label the order

To be able to search and select a specific order/position and change it, it needs to be labeled. Then you can search for that specific label and write a code that will change just that position with the same label.

Market Order 3.0 is a cBot that use the label to find information and execute it based on a code using the "label". Search the API in the forum for Label and you should get some answer how to solve it. Below is a simple code that closes a position using the label name.

if (position != null && Label == MyLabel)
                {
                    ClosePositionAsync(position);
                }

 

 


@kricka

iRobot
05 Nov 2016, 21:02

But what if I already have several open trades (opened at higher prices) with same labels?


@iRobot

kricka
05 Nov 2016, 21:32

Original label name for every order

The label name should be original for the order/position. If several orders have the same label name there will be a conflict. When an original order is placed it should be assigned with an original label name and by searching for that label name there should not be any conflict in finding it. That is why the code sending the original order should have a parameter to specify the label name. 


@kricka

iRobot
13 Nov 2016, 22:49

How the different labels are given?

Now I give labels to any trade like this: string labelB1_OnTrade = Symbol.Code.ToString() + " Long M30";

So it's the same label for every trade on specific symbol.

I don't know how to give different label names, and theoretically I would need infinite number of them.


@iRobot

... Deleted by UFO ...