# Plotting Average Actual Entry
# Mobius
# 01.01.2018
input HardStop = 3.00;
input Dir = {default long, short};
plot hide = double.nan;
hide.setDefaultColor(Color.Black);
def c = if isNaN(close[-1]) then close else c[1];
def Entry = if isNaN(GetAveragePrice())
then Entry[1]
else GetAveragePrice();
def LastEntryBar = if Entry != Entry[1]
then barNumber()
else LastEntryBar[1];
plot Entry_ = if barNumber() >= HighestAll(LastEntryBar) and Entry > 0
then highestAll(if isNaN(close[-1])
then Entry
else double.nan)
else double.nan;
Entry_.SetStyle(Curve.Long_Dash);
Entry_.SetLineWeight(3);
Entry_.SetDefaultColor(CreateColor(255,215,0));
Entry_.HideBubble();
Entry_.HideTitle();
def PL = if Entry > 0 then Entry - c else 0;
AddChartBubble(barNumber() == HighestAll(barNumber()), Entry_, "AVG " +AsDollars(Entry), Entry_.TakeValueColor());
#Alert(c crosses below Entry, "", Alert.Bar, Sound.Chimes);
#Alert(c crosses above Entry, "", Alert.Bar, Sound.Ring);
plot stop;
switch (Dir)
{
case long:
stop = Entry_ - HardStop;
case short:
stop = Entry_ + HardStop;
}
#Alert(close crosses stop, "STOP", Alert.Bar, Sound.Bell);
# End Code