//+------------------------------------------------------------------+
//|                                                  SimpleENTRY.mq4 |
//|                                                           smarco |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "smarco"

#property indicator_chart_window
#property indicator_buffers 0


extern string note1 = "----------------- EMAs --------------------";
extern int EMA = 10;
extern int EMATrend = 200;
extern string note2 = "------------------ Text -------------------";
extern int TextSize = 11;
extern int TextDistance = 15;
extern color TextBuyColor = RoyalBlue;
extern color TextSellColor = Red;
extern string TextFont = "Arial";
extern int TextSide = 0;
extern int TextX = 250;
extern int TextY = 10;

double EMAValue, EMATrendValue;

bool BUY = false;
bool SELL = false;

//-----------------------------------------------------------------------------------------
void init()
{
   ObjectCreate("SimpleENTRY_EMA", OBJ_LABEL, 0, 0, 0);
   ObjectSet("SimpleENTRY_EMA", OBJPROP_CORNER, TextSide);
   ObjectSet("SimpleENTRY_EMA", OBJPROP_XDISTANCE, TextX);
   ObjectSet("SimpleENTRY_EMA", OBJPROP_YDISTANCE, TextY);

   ObjectCreate("SimpleENTRY_PRICE", OBJ_LABEL, 0, 0, 0);
   ObjectSet("SimpleENTRY_PRICE", OBJPROP_CORNER, TextSide);
   ObjectSet("SimpleENTRY_PRICE", OBJPROP_XDISTANCE, TextX);
   ObjectSet("SimpleENTRY_PRICE", OBJPROP_YDISTANCE, TextY+TextDistance);
}

//-----------------------------------------------------------------------------------------
void deinit()
{
   ObjectDelete("SimpleENTRY_EMA");
   ObjectDelete("SimpleENTRY_PRICE");
}

//-----------------------------------------------------------------------------------------
int start()
{
   EMAValue = iMA(NULL, 0, EMA, 0, MODE_EMA, PRICE_CLOSE, 0);
   EMATrendValue = iMA(NULL, 0, EMATrend, 0, MODE_EMA, PRICE_CLOSE, 0);
   
   if (Bid <= (EMATrendValue)) {
      BUY  = false;
      SELL = true;
   }
   else {
      BUY  = true;
      SELL = false;
   }

   if (BUY) {
      ObjectSetText("SimpleENTRY_EMA", DoubleToStr(EMAValue,Digits) + " EMA" + EMA + " " + DoubleToStr(((Bid-EMAValue)/Point)/10,1) +" pips", TextSize, TextFont, TextBuyColor);
      ObjectSetText("SimpleENTRY_PRICE", DoubleToStr(Bid,Digits) + " PRICE (BUY)", TextSize, TextFont, TextBuyColor);
   }
   
   if (SELL) {
      ObjectSetText("SimpleENTRY_EMA", DoubleToStr(EMAValue,Digits) + " EMA" + EMA + " " + DoubleToStr(((EMAValue-Bid)/Point)/10,1) +" pips", TextSize, TextFont, TextSellColor);
      ObjectSetText("SimpleENTRY_PRICE", DoubleToStr(Bid,Digits) + " PRICE (SELL)", TextSize, TextFont, TextSellColor);
   }
   return(0);
}