PendingOrder
interface cAlgo.API
DesktopCLICloud
Provides access to properties of pending orders
Definition
public interface PendingOrder
Namespace: cAlgo.API · Group: Orders
Examples
Example 1
var limitPrice = Symbol.Bid - 20 * Symbol.PipSize;
var result = PlaceLimitOrder(TradeType.Buy, SymbolName, Symbol.QuantityToVolumeInUnits(0.01), limitPrice, "myLabel", 20, 40, ProtectionType.Relative);
if (result.IsSuccessful)
{
var order = result.PendingOrder;
Print("Order {0}: {1} {2} {3} at {4}", order.Id, order.OrderType, order.TradeType, order.VolumeInUnits, order.TargetPrice);
}
else
{
Print("Order placement failed: {0}", result.Error);
}
limitPrice = api.Symbol.Bid - 20 * api.Symbol.PipSize
result = api.PlaceLimitOrder(TradeType.Buy, api.SymbolName, api.Symbol.QuantityToVolumeInUnits(0.01), limitPrice, "myLabel", 20, 40, ProtectionType.Relative)
if result.IsSuccessful:
order = result.PendingOrder
api.Print(f"Order {order.Id}: {order.OrderType} {order.TradeType} {order.VolumeInUnits} at {order.TargetPrice}")
else:
api.Print(f"Order placement failed: {result.Error}")
Example 2
foreach (var order in PendingOrders.Where(pendingOrder => pendingOrder.Label == "myLabel").ToArray())
{
if (order.DistancePips > 50)
order.Cancel();
else
order.ModifyStopLossPips(15);
}
for order in [pendingOrder for pendingOrder in api.PendingOrders if pendingOrder.Label == "myLabel"]:
if order.DistancePips > 50:
order.Cancel()
else:
order.ModifyStopLossPips(15)
Example 3
protected override void OnStart()
{
PendingOrders.Filled += OnPendingOrdersFilled;
PendingOrders.Cancelled += OnPendingOrdersCancelled;
}
private void OnPendingOrdersFilled(PendingOrderFilledEventArgs args)
{
Print("Order {0} filled, position {1} opened", args.PendingOrder.Id, args.Position.Id);
}
private void OnPendingOrdersCancelled(PendingOrderCancelledEventArgs args)
{
Print("Order {0} cancelled, reason: {1}", args.PendingOrder.Id, args.Reason);
}
def on_start(self):
api.PendingOrders.Filled += self.on_pending_orders_filled
api.PendingOrders.Cancelled += self.on_pending_orders_cancelled
def on_pending_orders_filled(self, args):
api.Print(f"Order {args.PendingOrder.Id} filled, position {args.Position.Id} opened")
def on_pending_orders_cancelled(self, args):
api.Print(f"Order {args.PendingOrder.Id} cancelled, reason: {args.Reason}")
Methods
| Name | Description |
|---|---|
CancelDesktopCLICloudTradeResult | Shortcut for Robot.CancelPendingOrder method |
ModifyExpirationTimeDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change Expiration Time |
ModifyStopLimitRangeDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change Stop Limit Range |
ModifyStopLossBreakEvenDesktopCLICloudTradeResult | Shortcut for the Robot.ModifyPosition method to change the StopLoss Break-Even. |
ModifyStopLossPipsDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change Stop Loss |
ModifyStopLossPriceDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change Stop Loss |
ModifyTakeProfit 2 overloadsDesktopCLICloudTradeResult | Shortcut for the Robot.ModifyTakeProfit method to change the Take Profit protection |
ModifyTakeProfitPipsDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change Take Profit |
ModifyTakeProfitPriceDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change Take Profit |
ModifyTargetPriceDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change Target Price |
ModifyVolumeDesktopCLICloudTradeResult | Shortcut for Robot.ModifyPendingOrder method to change VolumeInUnits |
Properties
| Name | Description |
|---|---|
AbsoluteTakeProfitProtectionsDesktopCLICloudAbsoluteTakeProfitProtections | The absolute take profit protections of the order. Null if order has no take profit. |
ChannelDesktopCLICloudstring | Gets the channel via which the order was placed in a string format. |
CommentDesktopCLICloudstring | User assigned Order Comment |
CurrentPriceDesktopCLIClouddouble | Gets the current price of the symbol for which the pending order is placed. |
DistancePipsDesktopCLIClouddouble | Gets the distance in pips between the current price of the symbol and the target price of the pending order (via TargetPrice). |
ExpirationTimeDesktopCLICloudDateTime? | The order Expiration time The Timezone used is set in the Robot attribute |
HasTrailingStopDesktopCLICloudbool | When HasTrailingStop set to true, server updates Stop Loss every time position moves in your favor. |
IdDesktopCLICloudint | Unique order Id. |
LabelDesktopCLICloudstring | User assigned identifier for the order. |
LastUpdateTimeDesktopCLICloudDateTime? | Gets the time when an order was last updated. The timezone used is set in the algorithm class attribute. |
OrderTypeDesktopCLICloudPendingOrderType | Specifies whether this order is Stop or Limit. |
ProtectionTypeDesktopCLICloudProtectionType | Gets the order protection type. |
QuantityDesktopCLIClouddouble | Quantity (lots) of this order |
RelativeTakeProfitProtectionsDesktopCLICloudRelativeTakeProfitProtections | The relative take profit protections of the order. Null if order has no take profit. |
StopLimitRangePipsDesktopCLIClouddouble? | Maximum limit from order target price, where order can be executed. |
StopLossDesktopCLIClouddouble? | The order stop loss in price |
StopLossBreakEvenDesktopCLICloudStopLossBreakEven | The stop loss break even of the order. |
StopLossPipsDesktopCLIClouddouble? | The order stop loss in pips |
StopLossTriggerMethodDesktopCLICloudStopTriggerMethod? | Trigger method for order's StopLoss |
StopOrderTriggerMethodDesktopCLICloudStopTriggerMethod? | Determines how pending order will be triggered in case it is a StopOrder |
SubmittedTimeDesktopCLICloudDateTime | Gets the order submission time. |
SymbolDesktopCLICloudSymbol | Gets the order symbol. |
SymbolNameDesktopCLICloudstring | Gets the symbol name. |
TakeProfitDesktopCLIClouddouble? | The order take profit in price |
TakeProfitPipsDesktopCLIClouddouble? | The order take profit in pips |
TargetPriceDesktopCLIClouddouble | The order target price. |
TradeTypeDesktopCLICloudTradeType | Specifies whether this order is to buy or sell. |
VolumeInUnitsDesktopCLIClouddouble | Volume of this order. |
Deprecated members (2)
string SymbolCode {get;}— Use SymbolName insteadlong Volume {get;}— Use VolumeInUnits instead