//+------------------------------------------------------------------+
//|                                                     lilmoe.mq4   |
//|                                                           v1.1   |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property copyright "By NuckingFuts" 
#property link      "http://www.forexfactory.com/member.php?u=70235"

//---- ext settings
extern string LabelSettings = "---------Label Settings----------";
extern int    LabelPosition = 1; // 0=top-left, 1=top-right, 2=bottom-left, 3=bottom-right
extern int    TopOffset     = 50;
extern int    LeftOffset    = 60;
extern int    RightOffset   = 10;
extern color  TextColor     = Gold;
extern int    FontSize      = 8;
extern bool   DrawAsBG      = false;
extern string CCISettings   = "---------CCI Settings----------";
extern bool   ShowCCI       = true;
extern int    CCIPeriod     = 30;
extern string GannSettings  = "---------Gann Settings----------";
extern bool   ShowGann      = true;
extern int    GannLB        = 10;
extern string GannFile      = "Gann_HiLo";
extern string SMASettings   = "---------SMA Settings----------";
extern bool   ShowSMA       = true;
extern int    SMAPeriod     = 5;
extern string EMASettings   = "---------EMA Settings----------";
extern bool   ShowEMA       = true;
extern int    EMAPeriod     = 50;

/*
   The bar shift for our calculations (0 = current bar, 1 = previous bar)
*/
extern int    BarShift      = 0;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   if (BarShift < 0 || BarShift > Bars) BarShift = 0;
   if (GannFile == "") GannFile = "Gann_HiLo_Activator_v2";
   if (LabelPosition < 0 || LabelPosition > 3) LabelPosition = 1;
   return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   if (ShowCCI)
   {
      ObjectDelete("CCI");
      ObjectDelete("CCIv");
   }
   if (ShowEMA)
   {
      ObjectDelete("EMA");
      ObjectDelete("EMAv");
   }
   if (ShowSMA)
   {
      ObjectDelete("SMA");
      ObjectDelete("SMAv");
   }
   if (ShowGann)
   {
      ObjectDelete("GANN");
      ObjectDelete("GANNv");
   }
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int top    = TopOffset;
   int left   = LeftOffset;
   int right  = RightOffset;
   int offset = 0;
   
   if (ShowEMA)
   {
      double ema = iMA(NULL, 0, EMAPeriod, 0, MODE_EMA, PRICE_CLOSE, BarShift);
      SetLabel("EMA", "EMA ("+EMAPeriod+"): ", left, top);
      SetLabel("EMAv", DoubleToStr(ema, Digits), right, top);
      offset += 15;
   }
   if (ShowSMA)
   {
      double sma = iMA(NULL, 0, SMAPeriod, 0, MODE_SMA, PRICE_CLOSE, BarShift);
      SetLabel("SMA", "SMA ("+SMAPeriod+"): ", left, top-offset);
      SetLabel("SMAv", DoubleToStr(sma, Digits), right, top-offset);
      offset += 15;
   }
   if (ShowGann)
   {
      double gann = iCustom(NULL, 0, GannFile, GannLB, 0, BarShift);
      SetLabel("GANN", "Gann ("+GannLB+"): ", left, top-offset);
      SetLabel("GANNv", DoubleToStr(gann, Digits), right, top-offset);
      offset += 15;
   }
   if (ShowCCI)
   {
      double cci = iCCI(NULL, 0, CCIPeriod, PRICE_TYPICAL, BarShift);
      SetLabel("CCI", "CCI ("+CCIPeriod+"): ", left, top-offset);
      SetLabel("CCIv", DoubleToStr(cci, Digits), right, top-offset);
      offset += 15;
   }
   return(0);
}
//+------------------------------------------------------------------+
//| Create label object function                                     |
//+------------------------------------------------------------------+
int SetLabel(string objName, string txt, int x, int y) 
{
   ObjectCreate(objName, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(objName, txt, FontSize, "Arial", TextColor);
   ObjectSet(objName, OBJPROP_CORNER, LabelPosition);
   ObjectSet(objName, OBJPROP_XDISTANCE, x);
   ObjectSet(objName, OBJPROP_YDISTANCE, y);
   if (DrawAsBG) ObjectSet(objName, OBJPROP_BACK, true);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+