Skip to content

AbsoluteStopLossProtection

record cAlgo.API Since 5.8

DesktopCLICloud

Represents a stop loss defined at an absolute price level.

Definition

public class AbsoluteStopLossProtection

Namespace: cAlgo.API · Group: Trading

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}")

Constructors

Name Description
AbsoluteStopLossProtection 2 overloadsDesktopCLICloud Represents a stop loss defined at an absolute price level.

Properties

Name Description
PriceDesktopCLIClouddouble The absolute price at which the stop loss is triggered.