Skip to content

TradeResult

Summary

The result of a trade operation.

Signature

1
public sealed class TradeResult

Namespace

cAlgo.API

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");
             }
         }
     }
 }

Methods

ToString

Summary

The description of a trade result.

Signature

1
public string ToString()

Return Value

string

Examples

1
2
3
 TradeResult result = PlaceLimitOrder(TradeType.Sell, Symbol, 50000, Symbol.Ask);
 if (result.IsSuccessful)
     Print(result.ToString());

Properties

IsSuccessful

Summary

True if the trade is successful, false if there is an error.

Signature

1
public bool IsSuccessful {get;}

Return Value

bool

Examples

1
2
3
 TradeResult result = ExecuteMarketOrder(TradeType.Buy, Symbol, 20000);
 if (result.IsSuccessful)
     Print("Buy at {0}", result.Position.EntryPrice);

Error

Summary

The error code of an unsuccessful trade.

Signature

1
public ErrorCode? Error {get;}

Return Value

ErrorCode?

Examples

1
2
3
4
 var mySymbol = MarketData.GetSymbol("EURUSD");
 TradeResult result = ExecuteMarketOrder(TradeType.Sell, mySymbol, 1);
 if(!result.IsSuccessful)
     Print("Error: {0}", result.Error);

Position

Summary

The resulting position of a trade request.

Signature

1
public Position Position {get;}

Return Value

Position

Examples

1
2
3
 TradeResult result = ExecuteMarketOrder(TradeType.Sell, Symbol, 50000);
 if (result.IsSuccessful)
     Print("Sell at {0}", result.Position.EntryPrice);

PendingOrder

Summary

The resulting pending order of a trade request.

Signature

1
public PendingOrder PendingOrder {get;}

Return Value

PendingOrder

Examples

1
2
3
4
 TradeResult result = PlaceLimitOrder(TradeType.Sell, Symbol,
                     50000, Symbol.Ask, "myLabel", 10, null);
 if(result.IsSuccessful)
     Print("Order placed. SL: {0}", result.PendingOrder.StopLoss);