AbsoluteTakeProfitProtection constructor
constructor · AbsoluteTakeProfitProtection · cAlgo.API Since 5.8
DesktopCLICloud
Represents a partial take profit closing a portion of the order volume at an absolute price.
Overloads
| Signature | Description |
|---|---|
AbsoluteTakeProfitProtection(double Volume, double Price) | Represents a partial take profit closing a portion of the order volume at an absolute price. |
AbsoluteTakeProfitProtection(AbsoluteTakeProfitProtection original) |
AbsoluteTakeProfitProtection(double Volume, double Price)
Represents a partial take profit closing a portion of the order volume at an absolute price.
public AbsoluteTakeProfitProtection(double Volume, double Price)
AbsoluteTakeProfitProtection(Volume: float, Price: float)
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
Volume | double | float | The portion of the order volume to close when the take profit is triggered. |
Price | double | float | The absolute price at which the take profit is triggered. |
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}")
AbsoluteTakeProfitProtection(AbsoluteTakeProfitProtection original)
public AbsoluteTakeProfitProtection(AbsoluteTakeProfitProtection original)
AbsoluteTakeProfitProtection(original: AbsoluteTakeProfitProtection)
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
original | AbsoluteTakeProfitProtection | AbsoluteTakeProfitProtection |