TradeResult


Summary

The result of a trade operation.

Syntax

public class TradeResult : Object

Members

NameTypeSummary
Error PropertyThe error code of an unsuccessful trade.
IsSuccessful PropertyTrue if the trade is successful, false if there is an error.
PendingOrder PropertyThe resulting pending order of a trade request.
Position PropertyThe resulting position of a trade request.
ToString MethodThe description of a trade result.
TradeResult Method

Example 1

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

Example 2

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