//+------------------------------------------------------------------+
//|    11 Nov 2016              !_TRO_CCI_WIN_5TF_DOT2.mq4           |      
//+------------------------------------------------------------------+
#property copyright "AHGduP"
#property link      "!_TRO_CCI_WIN_5TF_DOT2"

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 EMPTY 
#property indicator_color2 EMPTY 
#property indicator_color3 EMPTY 
#property indicator_color4 EMPTY 
#property indicator_color5 EMPTY 

extern int CCI5_Period       = 2 ;
extern int CCI15_Period      = 2 ;
extern int CCI30_Period      = 2 ;
extern int CCI60_Period      = 2 ;
extern int CCI240_Period     = 2 ;

extern int OHLev_UpT          = 95 ;
extern int OHLev_UpB          = 60 ;
extern int OHLev_DownT        = 40;
extern int OHLev_DownB        = 5;

extern int        CCI_WIN5D  = 1;//*****************
extern int        Adj_UpDn   = 20;
extern int        Adj_LtRt   = 400;// ************
extern int        TextSize   = 10;
extern bool       ShowDots   = true;
extern string    Custom_Name = "RSi-10C";

string     item01, item02, item03, item04, item05, item06, item07, item08, item09, item10, item11;
int        obj_total,k;
string     name;  

double CCI5W[];
double CCI15W[];
double CCI30W[];
double CCI60W[];
double CCI240W[];
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int init()
 {
    IndicatorDigits(+2);
    IndicatorBuffers(5);
    SetIndexBuffer(0, CCI5W);
    SetIndexBuffer(1, CCI15W);
    SetIndexBuffer(2, CCI30W);
    SetIndexBuffer(3, CCI60W);
    SetIndexBuffer(4, CCI240W);
 
        item01 = Custom_Name + "DIR001";
        item02 = Custom_Name + "DIR002";
        item03 = Custom_Name + "DIR003";
        item04 = Custom_Name + "DIR004";
        item05 = Custom_Name + "DIR005";
        item06 = Custom_Name + "DIR006";
        item07 = Custom_Name + "DIR007";
        item08 = Custom_Name + "DIR008";
        item09 = Custom_Name + "DIR009";
        item10 = Custom_Name + "DIR010";
        item11 = Custom_Name + "DIR011";

//=============================MOD====================================================== 
         string  ThisName = Custom_Name;//E 
         string Text=ThisName;
         IndicatorShortName(Text); 
         SetIndexLabel(0,"");  
         return(0);  
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int deinit()
  {   
    obj_total= ObjectsTotal();  
    for (k= obj_total; k>=0; k--)
      {
      name= ObjectName(k); 
      if (StringSubstr(name,0,6) == Custom_Name ){ObjectDelete(name);}
      }
        return(0);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void start()
 {  
      int i,LoopBegin;
//=====================================================================================================
      
      int HHE,HVE,  C5LH, C5LV,  C15LH,C15LV,   C30LH, C30LV,   C60LH, C60LV,   C240LH, C240LV ;
      int           C5LHD,       C15LHD,        C30LHD,         C60LHD,         C240LHD ;
  if  (CCI_WIN5D==0)
      {                
                         HHE    = 820 +Adj_LtRt;  HVE     = 150 +Adj_UpDn ; 
                        C5LH    = 820 +Adj_LtRt;  C5LV    = 170 +Adj_UpDn ; 
                        C15LH   = 820 +Adj_LtRt;  C15LV   = 190 +Adj_UpDn ; 
                        C30LH   = 820 +Adj_LtRt;  C30LV   = 210 +Adj_UpDn ; 
                        C60LH   = 820 +Adj_LtRt;  C30LV   = 230 +Adj_UpDn ; 
                        C240LH  = 820 +Adj_LtRt;  C240LV  = 250 +Adj_UpDn ; 
           //DOTS--             
                        C5LHD    = 850 +Adj_LtRt; 
                        C15LHD   = 850 +Adj_LtRt; 
                        C30LHD   = 850 +Adj_LtRt;  
                        C60LHD   = 850 +Adj_LtRt; 
                        C240LHD  = 850 +Adj_LtRt; 
                        
      }
   if  (CCI_WIN5D==1||2||3||4)// dit skuif die hele ry!
      {                 
                        HHE     = 820 +Adj_LtRt;  HVE     = 10  +Adj_UpDn ; // 820
                        C5LH    = 820 +Adj_LtRt;  C5LV    = 25  +Adj_UpDn ; 
                        C15LH   = 820 +Adj_LtRt;  C15LV   = 45  +Adj_UpDn ; 
                        C30LH   = 820 +Adj_LtRt;  C30LV   = 65  +Adj_UpDn ; 
                        C60LH   = 820 +Adj_LtRt;  C60LV   = 85  +Adj_UpDn ; 
                        C240LH  = 820 +Adj_LtRt;  C240LV  = 105 +Adj_UpDn ; 
                        
           //DOTS--             
                        C5LHD    = 860 +Adj_LtRt;//850
                        C15LHD   = 860 +Adj_LtRt; 
                        C30LHD   = 860 +Adj_LtRt;  
                        C60LHD   = 860 +Adj_LtRt; 
                        C240LHD  = 860 +Adj_LtRt;             
      }

//========================================================================================== 
  
 for (i=LoopBegin; i>=0; i--) {
      
      CCI5W[i]     = iRSI(NULL, PERIOD_M5,  CCI5_Period,    PRICE_CLOSE, i);
      CCI15W[i]    = iRSI(NULL, PERIOD_M15, CCI15_Period,   PRICE_CLOSE, i);
      CCI30W[i]    = iRSI(NULL, PERIOD_M30, CCI30_Period,   PRICE_CLOSE, i);
      CCI60W[i]    = iRSI(NULL, PERIOD_H1,  CCI60_Period,   PRICE_CLOSE, i);
      CCI240W[i]   = iRSI(NULL, PERIOD_H4,  CCI240_Period,  PRICE_CLOSE, i);
      
     double CCI5WP     = iRSI(NULL, PERIOD_M5,  CCI5_Period,    PRICE_CLOSE, i+1);
     double CCI15WP    = iRSI(NULL, PERIOD_M15, CCI15_Period,   PRICE_CLOSE, i+1);
     double CCI30WP    = iRSI(NULL, PERIOD_M30, CCI30_Period,   PRICE_CLOSE, i+1);
     double CCI60WP    = iRSI(NULL, PERIOD_H1,  CCI60_Period,   PRICE_CLOSE, i+1);
     double CCI240WP   = iRSI(NULL, PERIOD_H4,  CCI240_Period,  PRICE_CLOSE, i+1);
      

//=======================  HEADINGE  ===============================================   
    
     ObjectCreate (item01, OBJ_LABEL,CCI_WIN5D, 0, 0);
     ObjectSetText(item01, "RSi-2  @  85/15" , TextSize, "Tahoma Bold", clrAqua);// 77
     ObjectSet    (item01, OBJPROP_XDISTANCE, HHE);
     ObjectSet    (item01, OBJPROP_YDISTANCE, HVE); 

//=======================  CCI  ======================================================================================================        
  
   {                             ObjectCreate (item02, OBJ_LABEL,CCI_WIN5D, 0, 0);
   if  (CCI5W[i] > OHLev_UpB )   {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold", clrLime);}
  if  (CCI5W[i] > OHLev_UpT )    {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);} 
  if  (CCI5W[i] < OHLev_DownT )  {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold",  clrRed);}
  if  (CCI5W[i] < OHLev_DownB )  {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
                                 ObjectSet    (item02, OBJPROP_XDISTANCE, C5LH);
                                 ObjectSet    (item02, OBJPROP_YDISTANCE, C5LV ); 
   }
   
   
   
    {                             ObjectCreate (item02, OBJ_LABEL,CCI_WIN5D, 0, 0);
  if  (CCI5W[i] > OHLev_UpB )    {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold", clrLime);}
  if  (CCI5W[i] > OHLev_UpT )    {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
  if  (CCI5W[i] < OHLev_DownT )  {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold", clrRed);}
  if  (CCI5W[i] < OHLev_DownB )  {ObjectSetText(item02,"(5)         "+DoubleToStr(CCI5W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
                                 ObjectSet    (item02, OBJPROP_XDISTANCE, C5LH);
                                 ObjectSet    (item02, OBJPROP_YDISTANCE, C5LV ); 
   }
   
   
   {                             ObjectCreate (item03, OBJ_LABEL,CCI_WIN5D, 0, 0);
  if  (CCI15W[i] > OHLev_UpB )   {ObjectSetText(item03,"(15)       "+DoubleToStr(CCI15W[i],0)+"", TextSize, "Tahoma Bold", clrLime);}
  if  (CCI15W[i] > OHLev_UpT )   {ObjectSetText(item03,"(15)       "+DoubleToStr(CCI15W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
  if  (CCI15W[i] < OHLev_DownT ) {ObjectSetText(item03,"(15)       "+DoubleToStr(CCI15W[i],0)+"", TextSize, "Tahoma Bold", clrRed);}
  if  (CCI15W[i] < OHLev_DownB ) {ObjectSetText(item03,"(15)       "+DoubleToStr(CCI15W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
                                 ObjectSet    (item03, OBJPROP_XDISTANCE, C15LH);
                                 ObjectSet    (item03, OBJPROP_YDISTANCE, C15LV ); 
   }
   
   {                             ObjectCreate (item04, OBJ_LABEL,CCI_WIN5D, 0, 0);
  if  (CCI30W[i] > OHLev_UpB )   {ObjectSetText(item04,"(30)       "+DoubleToStr(CCI30W[i],0)+"", TextSize, "Tahoma Bold", clrLime);}
  if  (CCI30W[i] > OHLev_UpT )   {ObjectSetText(item04,"(30)       "+DoubleToStr(CCI30W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
  if  (CCI30W[i] < OHLev_DownT ) {ObjectSetText(item04,"(30)       "+DoubleToStr(CCI30W[i],0)+"", TextSize, "Tahoma Bold", clrRed   );}
  if  (CCI30W[i] < OHLev_DownB ) {ObjectSetText(item04,"(30)       "+DoubleToStr(CCI30W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
                                 ObjectSet    (item04, OBJPROP_XDISTANCE, C30LH);
                                 ObjectSet    (item04, OBJPROP_YDISTANCE, C30LV ); 
   }
   
   {                             ObjectCreate (item05, OBJ_LABEL,CCI_WIN5D, 0, 0);
  if  (CCI60W[i] > OHLev_UpB )   {ObjectSetText(item05,"(H1)       "+DoubleToStr(CCI60W[i],0)+"", TextSize, "Tahoma Bold", clrLime);}
  if  (CCI60W[i] > OHLev_UpT )   {ObjectSetText(item05,"(H1)       "+DoubleToStr(CCI60W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
  if  (CCI60W[i] < OHLev_DownT ) {ObjectSetText(item05,"(H1)       "+DoubleToStr(CCI60W[i],0)+"", TextSize, "Tahoma Bold", clrRed   );}
  if  (CCI60W[i] < OHLev_DownB ) {ObjectSetText(item05,"(H1)       "+DoubleToStr(CCI60W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
                                 ObjectSet    (item05, OBJPROP_XDISTANCE, C60LH);
                                 ObjectSet    (item05, OBJPROP_YDISTANCE, C60LV ); 
   }
   
   {                             ObjectCreate (item06, OBJ_LABEL,CCI_WIN5D, 0, 0);
  if  (CCI240W[i] > OHLev_UpB )  {ObjectSetText(item06,"(H4)       "+DoubleToStr(CCI240W[i],0)+"", TextSize, "Tahoma Bold", clrLime);}
  if  (CCI240W[i] > OHLev_UpT )  {ObjectSetText(item06,"(H4)       "+DoubleToStr(CCI240W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
  if  (CCI240W[i] < OHLev_DownT) {ObjectSetText(item06,"(H4)       "+DoubleToStr(CCI240W[i],0)+"", TextSize, "Tahoma Bold", clrRed   );}
  if  (CCI240W[i] < OHLev_DownB ){ObjectSetText(item06,"(H4)       "+DoubleToStr(CCI240W[i],0)+"", TextSize, "Tahoma Bold", clrYellow);}
                                 ObjectSet    (item06, OBJPROP_XDISTANCE, C240LH);
                                 ObjectSet    (item06, OBJPROP_YDISTANCE, C240LV ); 
   }
   
//====================== DOT DIRECTION ================================================================================================
 if      (  ShowDots == true ){
     { ObjectCreate(item07, OBJ_LABEL,CCI_WIN5D, 0, 0); 
 //if  ((CCI5W[i] > 50 )&& (CCI5W[i] > CCI5WP )) {ObjectSetText("CCIT5D_lab5","é",10, "Wingdings", clrLime);}
 //if  ((CCI5W[i] > 50 )&& (CCI5W[i] < CCI5WP )) {ObjectSetText("CCIT5D_lab5","ê",10, "Wingdings", MediumSeaGreen);}
 if  ( (CCI5W[i] > CCI5WP )) {ObjectSetText(item07,"é",10, "Wingdings", clrLime);}
 if  ( (CCI5W[i] < CCI5WP )) {ObjectSetText(item07,"ê",10, "Wingdings", clrRed);}
 
//f  ( (CCI5W[i] > CCI5WP )) {ObjectSetText("CCIT5D_lab5","é",10, "Wingdings", clrRed);}
 //  ( (CCI5W[i] < CCI5WP )) {ObjectSetText("CCIT5D_lab5","ê",10, "Wingdings", IndianRed);}
     ObjectSet(item07, OBJPROP_XDISTANCE, C5LHD);
     ObjectSet(item07, OBJPROP_YDISTANCE, C5LV ); 
   }
   
   { ObjectCreate(item08, OBJ_LABEL,CCI_WIN5D, 0, 0); 
 if  ( (CCI15W[i] > CCI15WP )) {ObjectSetText(item08,"é",10, "Wingdings", clrLime);}
 if  ( (CCI15W[i] < CCI15WP )) {ObjectSetText(item08,"ê",10, "Wingdings", clrRed);}
     ObjectSet(item08, OBJPROP_XDISTANCE, C15LHD);
     ObjectSet(item08, OBJPROP_YDISTANCE, C15LV ); 
   }
   
   { ObjectCreate(item09, OBJ_LABEL,CCI_WIN5D, 0, 0); 
 if  ( (CCI30W[i] > CCI30WP )) {ObjectSetText(item09,"é",10, "Wingdings", clrLime);}
 if  ( (CCI30W[i] < CCI30WP )) {ObjectSetText(item09,"ê",10, "Wingdings", clrRed);}
     ObjectSet(item09, OBJPROP_XDISTANCE, C30LHD);
     ObjectSet(item09, OBJPROP_YDISTANCE, C30LV ); 
   }
   
   { ObjectCreate(item10, OBJ_LABEL,CCI_WIN5D, 0, 0); 
 if  ( (CCI60W[i] > CCI60WP )) {ObjectSetText(item10,"é",10, "Wingdings", clrLime);}
 if  ( (CCI60W[i] < CCI60WP )) {ObjectSetText(item10,"ê",10, "Wingdings", clrRed);}
     ObjectSet(item10, OBJPROP_XDISTANCE, C60LHD);
     ObjectSet(item10, OBJPROP_YDISTANCE, C60LV ); 
   }
   
   { ObjectCreate(item11, OBJ_LABEL,CCI_WIN5D, 0, 0); 
 if  ( (CCI240W[i] > CCI240WP )) {ObjectSetText(item11,"é",10, "Wingdings", clrLime);}
 if  ( (CCI240W[i] < CCI240WP )) {ObjectSetText(item11,"ê",10, "Wingdings", clrRed);}
     ObjectSet(item11, OBJPROP_XDISTANCE, C240LHD);
     ObjectSet(item11, OBJPROP_YDISTANCE, C240LV ); 
   }
   }
//======================================================================================+  
     }
     }
//======================================================================================+
//--------------------------------------------------------------------------------------+

