Skip to content

PendingOrder.ModifyTakeProfit

method · PendingOrder · cAlgo.API Since 5.8

DesktopCLICloud

Shortcut for the Robot.ModifyTakeProfit method to change the Take Profit protection

Overloads

ModifyTakeProfit(RelativeTakeProfitProtections takeProfitProtections)

Shortcut for the Robot.ModifyTakeProfit method to change the Take Profit protection

TradeResult ModifyTakeProfit(RelativeTakeProfitProtections takeProfitProtections)
pendingOrder.ModifyTakeProfit(takeProfitProtections: RelativeTakeProfitProtections) -> TradeResult

Parameters

Name C# type Python type Description
takeProfitProtections RelativeTakeProfitProtections RelativeTakeProfitProtections New Take Profit protections

Returns TradeResult

Examples

foreach (var order in PendingOrders)
{
    var halfVolume = order.Symbol.NormalizeVolumeInUnits(order.VolumeInUnits / 2, RoundingMode.Down);
    var takeProfits = new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(halfVolume, 20), new RelativeTakeProfitLastProtection(40));
    var result = order.ModifyTakeProfit(takeProfits);
    Print("Order {0} take profit ladder set: {1}", order.Id, result.IsSuccessful);
}
for order in api.PendingOrders:
    halfVolume = order.Symbol.NormalizeVolumeInUnits(order.VolumeInUnits / 2, RoundingMode.Down)
    takeProfits = RelativeTakeProfitProtections(RelativeTakeProfitProtection(halfVolume, 20), RelativeTakeProfitLastProtection(40))
    result = order.ModifyTakeProfit(takeProfits)
    api.Print(f"Order {order.Id} take profit ladder set: {result.IsSuccessful}")

ModifyTakeProfit(AbsoluteTakeProfitProtections takeProfitProtections)

Shortcut for the Robot.ModifyTakeProfit method to change the Take Profit protection

TradeResult ModifyTakeProfit(AbsoluteTakeProfitProtections takeProfitProtections)
pendingOrder.ModifyTakeProfit(takeProfitProtections: AbsoluteTakeProfitProtections) -> TradeResult

Parameters

Name C# type Python type Description
takeProfitProtections AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections New Take Profit protections

Returns TradeResult

Examples

foreach (var order in PendingOrders)
{
    var distance = 50 * order.Symbol.PipSize;
    var targetPrice = order.TradeType == TradeType.Buy ? order.TargetPrice + distance : order.TargetPrice - distance;
    var result = order.ModifyTakeProfit(new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitLastProtection(targetPrice)));
    Print("Order {0} take profit set at {1}: {2}", order.Id, targetPrice, result.IsSuccessful);
}
for order in api.PendingOrders:
    distance = 50 * order.Symbol.PipSize
    targetPrice = order.TargetPrice + distance if order.TradeType == TradeType.Buy else order.TargetPrice - distance
    result = order.ModifyTakeProfit(AbsoluteTakeProfitProtections(AbsoluteTakeProfitLastProtection(targetPrice)))
    api.Print(f"Order {order.Id} take profit set at {targetPrice}: {result.IsSuccessful}")