FindAll
Created at 22 May 2015, 12:15
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); } } } }
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