GetAveragePrice ( Symbol symbol);
symbol: current symbol
Returns the average trade price for a specified instrument, for 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.
|symbol||current symbol||Defines the instrument for which the average price will be returned.|
def qty = GetQuantity();
def openCost = qty * GetAveragePrice();
def netLiq = qty * close;
plot ManualOpenPL = netLiq - openCost;
plot AutoOpenPL = GetOpenPL();
This example script uses the
GetAveragePrice function along with
GetQuantity 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,
OpenCost formulas are to be multiplied by it.