close all position

Created at 24 Aug 2017, 18:35
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!
YO

yosifov

Joined 19.06.2017

close all position
24 Aug 2017, 18:35


Hallo,

I notice that my cBot closes also trades I have made manually in cTrader (same account and currency).
how can I force my cBot to modify/close ONLY positions genereted within cAlgo?

Thanks in advance.
Yosif


@yosifov
Replies

Spotware
25 Aug 2017, 10:31

Dear yosifov,

You can use labels to distinguish between different position types. For example, when opening a position from a cBot, you can apply a label as follows

ExecuteMarketOrder(TradeType.Buy,Symbol,1000,"MyLabel");

and then when you are modifying these positions you can filter your positions using the label. See below

foreach(var position in Positions.Find("MyLabel"))
{
 // Modify/Close positions
}

Let us know if this helps.

Best Regards,

cTrader Team


@Spotware

yosifov
25 Aug 2017, 10:35

RE:

Thanks a lot. ... that did the trick :)


@yosifov