TradeOperationoperation=ExecuteMarketOrderAsync(TradeType.Buy,Symbol,10000,"asynchronous");if(operation.IsExecuting){Print("Trade is executing");}else{if(operation.TradeResult.IsSuccessful)Print("Trade executed");}
1 2 3 4 5 6 7 8 91011121314151617181920
protectedoverridevoidOnStart(){Positions.Opened+=PositionsOnOpened;TradeOperationoperation=ExecuteMarketOrderAsync(TradeType.Buy,Symbol,10000,"asynchronous");ExecuteMarketOrder(TradeType.Buy,Symbol,10000,"synchronous",10,10);if(operation.IsExecuting){Print("Trade is executing");}else{if(operation.TradeResult.IsSuccessful)Print("Trade executed");}}privatevoidPositionsOnOpened(PositionOpenedEventArgsargs){varpos=args.Position;Print("Position {0} opened at {1}",pos.Label,pos.EntryPrice);}
1 2 3 4 5 6 7 8 910111213141516171819202122232425
usingcAlgo.API;namespacecAlgo.Robots{// This sample cBot shows how to use TradeOperation to monitor an async order execution/placement operation[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassTradeOperationSample:Robot{protectedoverridevoidOnStart(){vartradeOperation=ExecuteMarketOrderAsync(TradeType.Buy,SymbolName,Symbol.VolumeInUnitsMin,OnTradeResult);if(tradeOperation.IsExecuting){Print("Executing");}else{Print("Completed");}}privatevoidOnTradeResult(TradeResultobj){Print("Was Trade Operation Successful: ",obj.IsSuccessful);}}}