Skip to content

Position.ModifyTakeProfitPrice

method · Position · cAlgo.API

DesktopCLICloud

Shortcut for Robot.ModifyPosition method to change the Take Profit.

Definition

TradeResult ModifyTakeProfitPrice(double? takeProfit)
position.ModifyTakeProfitPrice(takeProfit: float | None) -> TradeResult

Parameters

Name C# type Python type Description
takeProfit double? float | None New Take Profit price

Returns TradeResult

Examples

var position = Positions.Find("myLabel");
if (position != null)
{
    var distance = 40 * position.Symbol.PipSize;
    var takeProfitPrice = position.TradeType == TradeType.Buy ? position.EntryPrice + distance : position.EntryPrice - distance;
    var result = position.ModifyTakeProfitPrice(takeProfitPrice);
    Print("Take profit modified: {0}", result.IsSuccessful);
}
position = api.Positions.Find("myLabel")
if position is not None:
    distance = 40 * position.Symbol.PipSize
    takeProfitPrice = position.EntryPrice + distance if position.TradeType == TradeType.Buy else position.EntryPrice - distance
    result = position.ModifyTakeProfitPrice(takeProfitPrice)
    api.Print(f"Take profit modified: {result.IsSuccessful}")