Position.ModifyTrailingStop
method · Position · cAlgo.API
DesktopCLICloud
Shortcut for the Robot.ModifyPosition method to change the Trailing Stop.
Definition
TradeResult ModifyTrailingStop(bool hasTrailingStop)
position.ModifyTrailingStop(hasTrailingStop: bool) -> TradeResult
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
hasTrailingStop | bool | bool | If true position will have trailing stop loss |
Returns TradeResult
Examples
var position = Positions.Find("myLabel");
if (position != null && position.StopLoss.HasValue)
{
var result = position.ModifyTrailingStop(true);
Print("Trailing stop enabled: {0}", result.IsSuccessful);
}
position = api.Positions.Find("myLabel")
if position is not None and position.StopLoss is not None:
result = position.ModifyTrailingStop(True)
api.Print(f"Trailing stop enabled: {result.IsSuccessful}")