Skip to content

AbsoluteStopLossProtection constructor

constructor · AbsoluteStopLossProtection · cAlgo.API Since 5.8

DesktopCLICloud

Represents a stop loss defined at an absolute price level.

Overloads

Signature Description
AbsoluteStopLossProtection(double Price) Represents a stop loss defined at an absolute price level.
AbsoluteStopLossProtection(AbsoluteStopLossProtection original)

AbsoluteStopLossProtection(double Price)

Represents a stop loss defined at an absolute price level.

public AbsoluteStopLossProtection(double Price)
AbsoluteStopLossProtection(Price: float)

Parameters

Name C# type Python type Description
Price double float The absolute price at which the stop loss is triggered.

Examples

var position = Positions.Find("myLabel");
if (position != null && position.TradeType == TradeType.Buy)
{
    var pipSize = position.Symbol.PipSize;
    var takeProfits = new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitLastProtection(position.EntryPrice + 40 * pipSize));
    var result = ModifyPosition(position, new AbsoluteStopLossProtection(position.EntryPrice - 20 * pipSize), takeProfits);
    Print("Stop loss set at {0}: {1}", position.EntryPrice - 20 * pipSize, result.IsSuccessful);
}
position = api.Positions.Find("myLabel")
if position is not None and position.TradeType == TradeType.Buy:
    pipSize = position.Symbol.PipSize
    takeProfits = AbsoluteTakeProfitProtections(AbsoluteTakeProfitLastProtection(position.EntryPrice + 40 * pipSize))
    result = api.ModifyPosition(position, AbsoluteStopLossProtection(position.EntryPrice - 20 * pipSize), takeProfits)
    api.Print(f"Stop loss set at {position.EntryPrice - 20 * pipSize}: {result.IsSuccessful}")

AbsoluteStopLossProtection(AbsoluteStopLossProtection original)

public AbsoluteStopLossProtection(AbsoluteStopLossProtection original)
AbsoluteStopLossProtection(original: AbsoluteStopLossProtection)

Parameters

Name C# type Python type Description
original AbsoluteStopLossProtection AbsoluteStopLossProtection