Skip to content

AbsoluteTakeProfitProtection

record cAlgo.API Since 5.8

DesktopCLICloud

Represents a partial take profit closing a portion of the order volume at an absolute price.

Definition

public class AbsoluteTakeProfitProtection

Namespace: cAlgo.API · Group: Trading

Examples

var position = Positions.Find("myLabel");
if (position != null && position.TradeType == TradeType.Buy)
{
    var pipSize = position.Symbol.PipSize;
    var halfVolume = position.Symbol.NormalizeVolumeInUnits(position.VolumeInUnits / 2, RoundingMode.Down);
    var firstTakeProfit = new AbsoluteTakeProfitProtection(halfVolume, position.EntryPrice + 20 * pipSize);
    var takeProfits = new AbsoluteTakeProfitProtections(firstTakeProfit, new AbsoluteTakeProfitLastProtection(position.EntryPrice + 40 * pipSize));
    Print("Take profit ladder set: {0}", position.ModifyTakeProfit(takeProfits).IsSuccessful);
}
position = api.Positions.Find("myLabel")
if position is not None and position.TradeType == TradeType.Buy:
    pipSize = position.Symbol.PipSize
    halfVolume = position.Symbol.NormalizeVolumeInUnits(position.VolumeInUnits / 2, RoundingMode.Down)
    firstTakeProfit = AbsoluteTakeProfitProtection(halfVolume, position.EntryPrice + 20 * pipSize)
    takeProfits = AbsoluteTakeProfitProtections(firstTakeProfit, AbsoluteTakeProfitLastProtection(position.EntryPrice + 40 * pipSize))
    api.Print(f"Take profit ladder set: {position.ModifyTakeProfit(takeProfits).IsSuccessful}")

Constructors

Name Description
AbsoluteTakeProfitProtection 2 overloadsDesktopCLICloud Represents a partial take profit closing a portion of the order volume at an absolute price.

Properties

Name Description
PriceDesktopCLIClouddouble The absolute price at which the take profit is triggered.
VolumeDesktopCLIClouddouble The portion of the order volume to close when the take profit is triggered.