GetQuantity ( Symbol symbol);

Default values:

symbol: current symbol


Returns the number of shares or contracts of a specified instrument held on the currently selected account.

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 shares/contracts quantity will be returned.


declare lower;

def qty = GetQuantity();
def openCost = qty * GetAveragePrice();
def netLiq = qty * close;

plot ManualOpenPL = netLiq - openCost;
plot AutoOpenPL = GetOpenPL();

This example script uses the GetQuantity function along with GetAveragePrice to manually calculate the Open Profit/Loss value. The resulting plot is shown with its automatic version calculated using the GetOpenPL function. The calculation is based on the execution price. 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, NetLiq and OpenCost formulas are to be multiplied by it.