Skip to content

Position.Reverse

method · Position · cAlgo.API

DesktopCLICloud

Shortcut for the Robot.ReversePosition method to change the direction of the trade.

Overloads

Signature Description
Reverse() Shortcut for the Robot.ReversePosition method to change the direction of the trade.
Reverse(double volume) Shortcut for the Robot.ReversePosition method to change the direction of trade and the volume.

Reverse()

Shortcut for the Robot.ReversePosition method to change the direction of the trade.

TradeResult Reverse()
position.Reverse() -> TradeResult

Returns TradeResult

Examples

var position = Positions.Find("myLabel");
if (position != null)
{
    var result = position.Reverse();
    if (result.IsSuccessful)
        Print("Position reversed to {0}", result.Position.TradeType);
}
position = api.Positions.Find("myLabel")
if position is not None:
    result = position.Reverse()
    if result.IsSuccessful:
        api.Print(f"Position reversed to {result.Position.TradeType}")

Reverse(double volume)

Shortcut for the Robot.ReversePosition method to change the direction of trade and the volume.

TradeResult Reverse(double volume)
position.Reverse(volume: float) -> TradeResult

Parameters

Name C# type Python type Description
volume double float New Volume in Units

Returns TradeResult

Examples

var position = Positions.Find("myLabel");
if (position != null)
{
    var result = position.Reverse(20000);
    if (result.IsSuccessful)
        Print("Position reversed to {0} {1}", result.Position.TradeType, result.Position.VolumeInUnits);
}
position = api.Positions.Find("myLabel")
if position is not None:
    result = position.Reverse(20000)
    if result.IsSuccessful:
        api.Print(f"Position reversed to {result.Position.TradeType} {result.Position.VolumeInUnits}")