Skip to content

TradeResult

Summary

The result of a trade operation.

Signature

1
public sealed class TradeResult

Namespace

cAlgo.API

Methods

Name Description
ToString The description of a trade result.

Properties

Name Description
IsSuccessful { get; } True if the trade is successful, false if there is an error.
Error { get; } The error code of an unsuccessful trade.
Position { get; } The resulting position of a trade request.
PendingOrder { get; } The resulting pending order of a trade request.

Examples

1
2
3
 TradeResult result = ExecuteMarketOrder(TradeType.Sell, Symbol, 20000);
 if (result.IsSuccessful)
     Print("Sell at {0}", result.Position.EntryPrice);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 using cAlgo.API;
 namespace cAlgo.Robots
 {
     // This sample cBot shows how to get a trade operation result
     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class TradeResultSample : Robot
     {
         protected override void OnStart()
         {
             var tradeResult = ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin);
             if (tradeResult.IsSuccessful)
             {
                 Print("Market order execution was successful");
                 var position = tradeResult.Position;
                 Print("A new position opend with ID ", position.Id);
             }
             else
             {
                 Print("Market order execution was not successful");
             }
         }
     }
 }

Last update: December 7, 2022

Comments