//+------------------------------------------------------------------+
//|                             Mn Prev Close Above Below Line.mq4 |
//+------------------------------------------------------------------+
#property copyright "Mn"
#property link      ""

#property indicator_chart_window

extern double mPriceLine = 0.0;
extern int mTime = 5,  mStyle = 0, mWidth = 2;
extern color mCol = Black;
bool AlertShort = false, AlertLong = false;

//+------------------------------------------------------------------+
int init()
  {
    ObjectCreate("PriceLine2", OBJ_HLINE, 0, 0, 0, 0, 0);
    ObjectSet("PriceLine2", OBJPROP_STYLE, mStyle);
    ObjectSet("PriceLine2", OBJPROP_WIDTH, mWidth);
    ObjectSet("PriceLine2", OBJPROP_PRICE1, mPriceLine);
    ObjectSet("PriceLine2", OBJPROP_COLOR, mCol);
    
    ObjectCreate("PriceText", OBJ_TEXT, 0, 0, 0, 0);
    ObjectSet("PriceText", OBJPROP_PRICE1, mPriceLine);
    ObjectSet("PriceText", OBJPROP_TIME1, Time[0]);
    ObjectSet("PriceText", OBJPROP_COLOR, mCol);


    if(Close[0] > mPriceLine)
       AlertShort = true;
    else   
       AlertLong = true;

    return(0);
  }

//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("PriceLine2");
   ObjectDelete("PriceText");
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   double mNewPrice = ObjectGet("PriceLine2", OBJPROP_PRICE1);
   ObjectSetText("PriceText", DoubleToStr(mNewPrice, Digits), 8, "Arial", mCol);
   ObjectSet("PriceText", OBJPROP_PRICE1, mNewPrice);

   
   if(AlertLong && Close[1] > mNewPrice)
    {
      AlertLong = false; AlertShort = true;
      Alert(Symbol(), "  Above ", mNewPrice);
    }

   if(AlertShort && Close[1] < mNewPrice)
    {
      AlertShort = false; AlertLong = true;
      Alert(Symbol(), "  Below ", mNewPrice);
    }

   return(0);
  }
//+------------------------------------------------------------------+