GetOpenPL ( Symbol symbol, int profitLossMode);

Default values:

symbol: current symbol profitLossMode: ProfitLossMode.EXECUTION_PRICE


Returns the Open Profit/Loss value for a specified symbol, for the currently selected account. This value is the difference between a position’s net liquidation value and either execution price or cost basis times the position size, based on the profitLossMode parameter value. Cost basis values are provided by Gainskeeper and include the effects of commissions and tax elections. By default, the value is returned based on the execution price; however, you can use ProfitLossMode constants to switch between the modes.

Note: there are certain limitations of usage of Portfolio functions; for more information on that, refer to the Portfolio functions index page.

Input Parameters

Parameter Default value Description
symbol current symbol Defines the instrument for which the Open Profit/Loss will be returned.
profitLossMode ProfitLossMode.EXECUTION_PRICE Defines whether the Open Profit/Loss value is to be calculated based on the execution price or cost basis.


declare lower;

def openCost = GetQuantity() * GetAveragePrice();

plot PercentPL = GetOpenPL() / AbsValue(openCost) * 100;
PercentPL.AssignValueColor(if PercentPL >= 0 then Color.UPTICK else Color.DOWNTICK);

This example script calculates and plots the P/L% value using three of the Portfolio functions: GetOpenPL, GetQuantity, and GetAveragePrice. The calculation is based on the execution price. Positive parts of the plot are colored green and the negative ones red. Note that manual calculation of Open Profit/Loss used in this script is only valid for symbols with a dollar value equal to 1. For instruments that have a different dollar value, the OpenCost formula is to be multiplied by it.