Skip to content

Plugin.ModifyPosition

method · Plugin · cAlgo.API

DesktopCLICloud

Modify the volume of a position

Environment behaviour

CLI — not supported. Plugins cannot run in the CLI: ctrader-cli runs cBots only.

Cloud — not supported. Plugins cannot run in the cloud: it runs cBots only.

Overloads

Signature Description
ModifyPosition(Position position, double volume) Modify the volume of a position
ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType) Modify the protection of a position
ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits) Modify the protection of a position
ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits) Modify the protection of a position
ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven) Modify the protection of a position
ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven) Modify the protection of a position
ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop) Modify the protection of a position
ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop) Modify the protection of a position
ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop) Modify the protection of a position
ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven) Modify the protection of a position
ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven) Modify the protection of a position
ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod) Modify the protection of a position
ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod) Modify the protection of a position
ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod) Modify the protection of a position
ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven) Modify the protection of a position
ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven) Modify the protection of a position

ModifyPosition(Position position, double volume)

Modify the volume of a position

public TradeResult ModifyPosition(Position position, double volume)
api.ModifyPosition(position: Position, volume: float) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
volume double float Volume (in units) of Trade

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], 10000);
api.ModifyPosition(api.Positions[0], 10000)

ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType)
api.ModifyPosition(position: Position, stopLoss: float | None, takeProfit: float | None, protectionType: ProtectionType | None) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss double? float | None New stop loss
takeProfit double? float | None New take profit
protectionType ProtectionType? ProtectionType | None Protection type

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], 10, 20, ProtectionType.Relative);
api.ModifyPosition(api.Positions[0], 10, 20, ProtectionType.Relative)

ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits)
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss RelativeStopLossProtection RelativeStopLossProtection Relative Stop loss
takeProfits RelativeTakeProfitProtections RelativeTakeProfitProtections Relative Take profits

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)));
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)))

ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits)
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss AbsoluteStopLossProtection AbsoluteStopLossProtection Absolute Stop loss
takeProfits AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections Absolute Take profits

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)));
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)))

ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, stopLossBreakEven: StopLossBreakEven) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss RelativeStopLossProtection RelativeStopLossProtection Relative Stop loss
takeProfits RelativeTakeProfitProtections RelativeTakeProfitProtections Relative Take profits
stopLossBreakEven StopLossBreakEven StopLossBreakEven Break-even for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), new StopLossBreakEven(15, 3));
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), StopLossBreakEven(15, 3))

ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, stopLossBreakEven: StopLossBreakEven) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss AbsoluteStopLossProtection AbsoluteStopLossProtection Absolute Stop loss
takeProfits AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections Absolute Take profits
stopLossBreakEven StopLossBreakEven StopLossBreakEven Break-even for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), new StopLossBreakEven(15, 3));
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), StopLossBreakEven(15, 3))

ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop)
api.ModifyPosition(position: Position, stopLoss: float | None, takeProfit: float | None, protectionType: ProtectionType | None, hasTrailingStop: bool) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss double? float | None New stop loss
takeProfit double? float | None New take profit
protectionType ProtectionType? ProtectionType | None Protection type
hasTrailingStop bool bool Enable/disable TrailingStop for position

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], 10, 20, ProtectionType.Relative, true);
api.ModifyPosition(api.Positions[0], 10, 20, ProtectionType.Relative, True)

ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop)
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss RelativeStopLossProtection RelativeStopLossProtection Relative Stop loss
takeProfits RelativeTakeProfitProtections RelativeTakeProfitProtections Relative Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true);
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True)

ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop)
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss AbsoluteStopLossProtection AbsoluteStopLossProtection Absolute Stop loss
takeProfits AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections Absolute Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true);
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True)

ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool, stopLossBreakEven: StopLossBreakEven) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss RelativeStopLossProtection RelativeStopLossProtection Relative Stop loss
takeProfits RelativeTakeProfitProtections RelativeTakeProfitProtections Relative Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position
stopLossBreakEven StopLossBreakEven StopLossBreakEven Break-even for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true, new StopLossBreakEven(15, 3));
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True, StopLossBreakEven(15, 3))

ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool, stopLossBreakEven: StopLossBreakEven) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss AbsoluteStopLossProtection AbsoluteStopLossProtection Absolute Stop loss
takeProfits AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections Absolute Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position
stopLossBreakEven StopLossBreakEven StopLossBreakEven Break-even for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true, new StopLossBreakEven(15, 3));
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True, StopLossBreakEven(15, 3))

ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)
api.ModifyPosition(position: Position, stopLoss: float | None, takeProfit: float | None, protectionType: ProtectionType | None, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss double? float | None New stop loss
takeProfit double? float | None New take profit
protectionType ProtectionType? ProtectionType | None Protection type
hasTrailingStop bool bool Enable/disable TrailingStop for position
stopLossTriggerMethod StopTriggerMethod? StopTriggerMethod | None Trigger method for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], 10, 20, ProtectionType.Relative, true, StopTriggerMethod.Trade);
api.ModifyPosition(api.Positions[0], 10, 20, ProtectionType.Relative, True, StopTriggerMethod.Trade)

ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss RelativeStopLossProtection RelativeStopLossProtection Relative Stop loss
takeProfits RelativeTakeProfitProtections RelativeTakeProfitProtections Relative Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position
stopLossTriggerMethod StopTriggerMethod? StopTriggerMethod | None Trigger method for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade);
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade)

ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss AbsoluteStopLossProtection AbsoluteStopLossProtection Absolute Stop loss
takeProfits AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections Absolute Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position
stopLossTriggerMethod StopTriggerMethod? StopTriggerMethod | None Trigger method for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade);
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade)

ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None, stopLossBreakEven: StopLossBreakEven) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss RelativeStopLossProtection RelativeStopLossProtection Relative Stop loss
takeProfits RelativeTakeProfitProtections RelativeTakeProfitProtections Relative Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position
stopLossTriggerMethod StopTriggerMethod? StopTriggerMethod | None Trigger method for position's StopLoss
stopLossBreakEven StopLossBreakEven StopLossBreakEven Break-even for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade, new StopLossBreakEven(15, 3));
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade, StopLossBreakEven(15, 3))

ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None, stopLossBreakEven: StopLossBreakEven) -> TradeResult

Parameters

Name C# type Python type Description
position Position Position Position which is affected
stopLoss AbsoluteStopLossProtection AbsoluteStopLossProtection Absolute Stop loss
takeProfits AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections Absolute Take profits
hasTrailingStop bool bool Enable/disable TrailingStop for position
stopLossTriggerMethod StopTriggerMethod? StopTriggerMethod | None Trigger method for position's StopLoss
stopLossBreakEven StopLossBreakEven StopLossBreakEven Break-even for position's StopLoss

Returns TradeResult — Trade Result

Examples

ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade, new StopLossBreakEven(15, 3));
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade, StopLossBreakEven(15, 3))