Skip to content

ToString Method

ToString

Summary

The description of a trade operation

Signature

1
public string ToString()

Return Value

string

Declaring Type

cAlgo.API.TradeOperation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 TradeOperation operation = 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
 9
10
11
12
13
14
15
16
17
18
19
20
 protected override void OnStart()
 {
     Positions.Opened += PositionsOnOpened;
     TradeOperation operation = 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");
     }
 }
 private void PositionsOnOpened(PositionOpenedEventArgs args)
 {
     var pos = args.Position;
     Print("Position {0} opened at {1}", pos.Label, pos.EntryPrice);
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 using cAlgo.API;
 namespace cAlgo.Robots
 {
     // This sample cBot shows how to use TradeOperation to monitor an async order execution/placement operation
     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class TradeOperationSample : Robot
     {
         protected override void OnStart()
         {
             var tradeOperation = ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, OnTradeResult);
             if (tradeOperation.IsExecuting)
             {
                 Print("Executing");
             }
             else
             {
                 Print("Completed");
             }
         }
         private void OnTradeResult(TradeResult obj)
         {
             Print("Was Trade Operation Successful: ", obj.IsSuccessful);
         }
     }
 }

Last update: June 26, 2022

Comments