PendingOrder.ModifyStopLossPrice
method · PendingOrder · cAlgo.API Since 5.1
DesktopCLICloud
Shortcut for Robot.ModifyPendingOrder method to change Stop Loss
Definition
TradeResult ModifyStopLossPrice(double? stopLoss)
pendingOrder.ModifyStopLossPrice(stopLoss: float | None) -> TradeResult
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
stopLoss | double? | float | None | New Stop Loss value in Price |
Returns TradeResult
Examples
foreach (var order in PendingOrders)
{
var distance = 20 * order.Symbol.PipSize;
var stopLossPrice = order.TradeType == TradeType.Buy ? order.TargetPrice - distance : order.TargetPrice + distance;
var result = order.ModifyStopLossPrice(stopLossPrice);
Print("Order {0} stop loss set at {1}: {2}", order.Id, stopLossPrice, result.IsSuccessful);
}
for order in api.PendingOrders:
distance = 20 * order.Symbol.PipSize
stopLossPrice = order.TargetPrice - distance if order.TradeType == TradeType.Buy else order.TargetPrice + distance
result = order.ModifyStopLossPrice(stopLossPrice)
api.Print(f"Order {order.Id} stop loss set at {stopLossPrice}: {result.IsSuccessful}")