FindAll

Created at 22 May 2015, 12:15
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!
MA

maxwell

Joined 22.05.2015

FindAll
22 May 2015, 12:15


Hi,

 

can someone explain me this method?  I mean I open two orders here and FindAll should only find those two positions right? But above the code in the guide is written:

"On each incoming new bar, the cBot will look for the order with one of the two labels and close only half of it, if the volume is equal to or greater than 20,000".

Do I loop here through all positions from other traders not only my positions??

 

 

[Robot()]
public class Sample_cBot : Robot
{
    protected override void OnStart()
    {
        ExecuteMarketOrder(TradeType.Buy, Symbol, 20000, "myLabel");
        ExecuteMarketOrder(TradeType.Buy, Symbol, 30000, "myLabel");
    }
 
    protected override void OnTick()
    {
        var positions = Positions.FindAll("myLabel", Symbol, TradeType.Buy);
 
        foreach (var position in positions)
        {
            if (position.Volume >= 20000)
            {
                ClosePosition(position, 15000);
            }
        }
    }
}

 


@maxwell
Replies

Spotware
16 Jun 2015, 12:50

Dear Trader,

You loop through all Positions labeled with “myLabel” opened in your current account. An example is shown in the API/References section of cTDN website.


@Spotware