**GetAveragePrice Horizontal Line**
Hello,

Is it possible to have a line on the chart that shows your current average price in a position in a trade? Kinda like this horizontal line, but it appears after you take a position and updates every time your avg price per share changes (if you buy/sell more shares).

Code:

```
# Dynamic Line
# zzz
# 11.18.2015
# Plots a horizontal line beginning on the closing value x number of bars ago
# Set Detrend to the number of bars ago you want to begin drawing the line
# Add code to plot a continuous price line into the right expansion area by
# the specified number of bars
#
# This version is actually simpler and works better than the previous version
# as it would not work if you chose detrend (unlikely choice). If "linefrom"
# is a negative number, it will plot back into the chart bars; if you use a
# positive number, it will plot only in the expansion area.
input linefrom = -60;#Hint linefrom: negative numbers plot in candle area, positive in expansion
input lineto = 60;#Hint lineto: limits how far into expansion the line will plot
input detrend = 0;#Hint detrend: usually zero. if you want a prior period, then enter a positive number
input price = close;
def lastbar = if IsNaN(close[-1]) and !IsNaN(close)
then BarNumber()
else lastbar[1];
def c = HighestAll(if IsNaN(close[-1]) and !IsNaN(close)
then price[detrend]
else Double.NaN);
plot Data = if BarNumber() >= highestall(lastbar + linefrom) and
BarNumber() <= highestall(lastbar + lineto)
then c
else Double.NaN;
# End Study
```

I don't want the horizontal line to show what it is showing now, I just need it to draw the horizontal line for GetAveragePrice(); but I am not sure what to remove and where to add GetAveragePrice();

I have also tried this, but still, no line is being drawn for the average price. Is that weird?

Code:

```
plot plBuy;
#plBuy = 791.5533;
plBuy = GetAveragePrice();
plBuy.SetDefaultColor(Color.RED);
plBuy.SetLineWeight(3);
addLabel(YES,plBuy,color.yellow);
```

Any help would be greatly appreciated!