Definition
Calculates the unrealized PnL for the position.
Method Return Value
A double value representing the unrealized PnL.
Syntax
Position.GetProfitLoss(double marketPrice, PerformanceUnit performanceUnit)
Parameters
marketPrice
|
Price used to calculate the PnL such as Close[0]. This value is used as the current price and compared against your entry price for the PnL.
|
performanceUnit
|
Possible values:
PerformanceUnit.Currency
PerformanceUnit.Percent
PerformanceUnit.Points
|
Examples
protected override void OnBarUpdate()
{
if (Position.MarketPosition != MarketPosition.Flat)
Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points));
}
|
|
|