#ToR_1.23





//+------------------------------------------------------------------+
//|                                                     ToR_1.23.mq4 |
//|                                             Trending or Ranging? |
//|                                       Copyright © 2008 Tom Balfe |
//|                                                 Modified by Kris |
//|                                                                  |
//| This indicator shows you whether a pair is trending or ranging.  | 
//| For trending markets use moving averages and for ranging         |
//| market use oscillators.                                          |
//|                                                                  |
//| Changelog:                                                       |
//|     1.23 - dropped M1 timeframe and included H4                  |
//|     1.21 - re-arranged layout                                    |
//|     1.20 - added CCI                                             |
//|     1.12 - made color assignment more efficient, made arrow      |
//|            assignment more efficient                             |
//|     1.11 - adjusted fonts, spacing, added ranging, text broken   |
//|     1.10 - added ADX increasing and decreasing notice            |
//|     1.03 - adjusted spacing, fonts, unreleased                   |
//|     1.02 - added arrows, ranging icon, no zero space state       |
//|            for icons/arrows, spacing got messed up, now          | 
//|            fixed                                                 |
//|     1.01 - unreleased, Reduced number of colors, functional      |
//|     1.0  - unreleased, too many colors for ADX values            |
//|                                                                  |
//|                   http://www.forex-tsd.com/members/nittany1.html |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007-2008 Tom Balfe"
#property link      "redcarsarasota@yahoo.com"
#property indicator_separate_window
//---- user selectable stuff
extern string  ADX_Settings         = "=== ADX Settings ===";
extern int     ADX_trend_level      = 22;
extern int     ADX_trend_strong     = 28;
extern string  CCI_Settings         = "=== CCI Settings ===";
extern int     M1_EntryCCI_Period   = 14;
extern int     M1_TrendCCI_Period   = 50;
extern int     M5_EntryCCI_Period   = 14;
extern int     M5_TrendCCI_Period   = 34;
extern int     M15_EntryCCI_Period  = 6;
extern int     M15_TrendCCI_Period  = 14;
extern int     M30_EntryCCI_Period  = 6;
extern int     M30_TrendCCI_Period  = 14;
extern int     H1_EntryCCI_Period  = 6;
extern int     H1_TrendCCI_Period  = 14;
extern int     H4_EntryCCI_Period  = 6;
extern int     H4_TrendCCI_Period  = 14;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- indicator short name
   IndicatorShortName("ToR 1.23 ");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   //---- need to delete objects should user remove indicator
   ObjectsDeleteAll(0,OBJ_LABEL);
     ObjectDelete("ToR120-1");ObjectDelete("ToR120-2");ObjectDelete("ToR120-3");
     ObjectDelete("ToR120-3a");ObjectDelete("ToR120-4");ObjectDelete("ToR120-4a");
     ObjectDelete("ToR120-4d");ObjectDelete("ToR120-5");ObjectDelete("ToR120-6");
     ObjectDelete("ToR120-6a");ObjectDelete("ToR120-6d");ObjectDelete("ToR120-7");
     ObjectDelete("ToR120-8");ObjectDelete("ToR120-8a");ObjectDelete("ToR120-8d");
     ObjectDelete("ToR120-9");ObjectDelete("ToR120-10");ObjectDelete("ToR120-10a");
     ObjectDelete("ToR120-10d");ObjectDelete("ToR120-11");ObjectDelete("ToR120-12");
     ObjectDelete("ToR120-12a");ObjectDelete("ToR120-13");ObjectDelete("ToR120-12d");
     ObjectDelete("ToR120-14");ObjectDelete("ToR120-15");ObjectDelete("ToR120-18d");
     ObjectDelete("ToR120-30e");ObjectDelete("ToR120-30t");
     ObjectDelete("ToR120-240e");ObjectDelete("ToR120-241e");ObjectDelete("ToR120-242e");
     ObjectDelete("ToR120-cci1");ObjectDelete("ToR120-cci2");ObjectDelete("ToR120-cci3");
     ObjectDelete("ToR120-cci4");ObjectDelete("ToR120-cci1a");ObjectDelete("ToR120-cci1b");
     ObjectDelete("ToR120-cci1c");ObjectDelete("ToR120-cci5");ObjectDelete("ToR120-cci6");
     ObjectDelete("ToR120-cci7");ObjectDelete("ToR120-cci8");ObjectDelete("ToR120-cci5b");
     ObjectDelete("ToR120-cci5c");ObjectDelete("ToR120-cci9");ObjectDelete("ToR120-cci10");
     ObjectDelete("ToR120-cci11");ObjectDelete("ToR120-cci12");ObjectDelete("ToR120-9b");
     ObjectDelete("ToR120-cci9c");
     ObjectDelete("ToR120-cci30e");ObjectDelete("ToR120-cci30t");
     ObjectDelete("ToR120-cci60e");ObjectDelete("ToR120-cci60t");
   return(0);
  }

int start()
  {
   //---- let's define some stuff 
   // M1 ADX data
   double adx_m1 = iADX(NULL,1,14,PRICE_CLOSE,0,0); // ADX 1 min
   double adx_1ago_m1 = iADX(NULL,1,14,PRICE_CLOSE,0,1); // ADX 1 min 1 bar ago
   double di_p_m1 = iADX(NULL,1,14,PRICE_CLOSE,1,0); // DI+ 1 min
   double di_m_m1 = iADX(NULL,1,14,PRICE_CLOSE,2,0); // DI- 1 min
   // M5 ADX data
   double adx_m5 = iADX(NULL,5,14,PRICE_CLOSE,0,0); // ADX 5 min
   double adx_1ago_m5 = iADX(NULL,5,14,PRICE_CLOSE,0,1); // ADX 5 min 1 bar ago
   double di_p_m5 = iADX(NULL,5,14,PRICE_CLOSE,1,0); // DI+ 5 min
   double di_m_m5 = iADX(NULL,5,14,PRICE_CLOSE,2,0); // DI- 5 min
   // M15 ADX data
   double adx_m15 = iADX(NULL,15,14,PRICE_CLOSE,0,0); // ADX 15 min
   double adx_1ago_m15 = iADX(NULL,15,14,PRICE_CLOSE,0,1); // ADX 15 min 1 bar ago
   double di_p_m15 = iADX(NULL,15,14,PRICE_CLOSE,1,0); // DI+ 15 min
   double di_m_m15 = iADX(NULL,15,14,PRICE_CLOSE,2,0); // DI- 15 min
   // M30 ADX data
   double adx_m30 = iADX(NULL,30,14,PRICE_CLOSE,0,0); // ADX 30 min
   double adx_1ago_m30 = iADX(NULL,30,14,PRICE_CLOSE,0,1); // ADX 30 min 1 bar ago
   double di_p_m30 = iADX(NULL,30,14,PRICE_CLOSE,1,0); // DI+ 30 min
   double di_m_m30 = iADX(NULL,30,14,PRICE_CLOSE,2,0); // DI- 30 min
   // H1 ADX data
   double adx_h1 = iADX(NULL,60,14,PRICE_CLOSE,0,0); // ADX 1 hour
   double adx_1ago_h1 = iADX(NULL,60,14,PRICE_CLOSE,0,1); // ADX 1 hr 1 bar ago
   double di_p_h1 = iADX(NULL,60,14,PRICE_CLOSE,1,0); // DI+ 1 hour
   double di_m_h1 = iADX(NULL,60,14,PRICE_CLOSE,2,0); // DI- 1 hour
   // H4 ADX data
   double adx_h4 = iADX(NULL,240,14,PRICE_CLOSE,0,0); // ADX 4 hour
   double adx_1ago_h4 = iADX(NULL,240,14,PRICE_CLOSE,0,1); // ADX 4 hr 1 bar ago
   double di_p_h4 = iADX(NULL,240,14,PRICE_CLOSE,1,0); // DI+ 4 hour
   double di_m_h4 = iADX(NULL,240,14,PRICE_CLOSE,2,0); // DI- 4 hour
      
   // M1 CCI data
   double cci_entry_m1 = iCCI(NULL,1,M1_EntryCCI_Period,PRICE_TYPICAL,0); 
   double cci_trend_m1 = iCCI(NULL,1,M1_TrendCCI_Period,PRICE_TYPICAL,0); 
   double cci_entry_1ago_m1 = iCCI(NULL,1,M1_EntryCCI_Period,PRICE_TYPICAL,1); 
   double cci_trend_1ago_m1 = iCCI(NULL,1,M1_TrendCCI_Period,PRICE_TYPICAL,1);
   // M5 CCI data
   double cci_entry_m5 = iCCI(NULL,5,M5_EntryCCI_Period,PRICE_TYPICAL,0);
   double cci_trend_m5 = iCCI(NULL,5,M5_TrendCCI_Period,PRICE_TYPICAL,0);
   double cci_entry_1ago_m5 = iCCI(NULL,5,M5_EntryCCI_Period,PRICE_TYPICAL,1);
   double cci_trend_1ago_m5 = iCCI(NULL,5,M5_TrendCCI_Period,PRICE_TYPICAL,1);
   // M15 CCI data
   double cci_entry_m15 = iCCI(NULL,15,M15_EntryCCI_Period,PRICE_TYPICAL,0);
   double cci_trend_m15 = iCCI(NULL,15,M15_TrendCCI_Period,PRICE_TYPICAL,0);
   double cci_entry_1ago_m15 = iCCI(NULL,15,M15_EntryCCI_Period,PRICE_TYPICAL,1);
   double cci_trend_1ago_m15 = iCCI(NULL,15,M15_TrendCCI_Period,PRICE_TYPICAL,1);   
   // M30 CCI data
   double cci_entry_m30 = iCCI(NULL,30,M30_EntryCCI_Period,PRICE_TYPICAL,0);
   double cci_trend_m30 = iCCI(NULL,30,M30_TrendCCI_Period,PRICE_TYPICAL,0);
   double cci_entry_1ago_m30 = iCCI(NULL,30,M30_EntryCCI_Period,PRICE_TYPICAL,1);
   double cci_trend_1ago_m30 = iCCI(NULL,30,M30_TrendCCI_Period,PRICE_TYPICAL,1);   
   // H1 CCI data
   double cci_entry_h1 = iCCI(NULL,60,H1_EntryCCI_Period,PRICE_TYPICAL,0);
   double cci_trend_h1 = iCCI(NULL,60,H1_TrendCCI_Period,PRICE_TYPICAL,0);
   double cci_entry_1ago_h1 = iCCI(NULL,60,H1_EntryCCI_Period,PRICE_TYPICAL,1);
   double cci_trend_1ago_h1 = iCCI(NULL,60,H1_TrendCCI_Period,PRICE_TYPICAL,1); 
   // H4 CCI data
   double cci_entry_h4 = iCCI(NULL,240,H4_EntryCCI_Period,PRICE_TYPICAL,0);
   double cci_trend_h4 = iCCI(NULL,240,H4_TrendCCI_Period,PRICE_TYPICAL,0);
   double cci_entry_1ago_h4 = iCCI(NULL,240,H4_EntryCCI_Period,PRICE_TYPICAL,1);
   double cci_trend_1ago_h4 = iCCI(NULL,240,H4_TrendCCI_Period,PRICE_TYPICAL,1);
   //---- define colors and arrows 
   color adx_color_m1,adx_color_m5,adx_color_m15,adx_color_m30,adx_color_h1,adx_color_h4,
         cci_color_entry_m1,cci_color_entry_m5,cci_color_entry_m15, cci_color_trend_m1,
         cci_color_trend_m5,cci_color_trend_m15,cci_color_entry_m30,cci_color_trend_m30,
         cci_color_entry_h1,cci_color_trend_h1,cci_color_trend_h4,cci_color_entry_h4;
   string adx_arrow_m1,adx_arrow_m5,adx_arrow_m15,adx_arrow_m30,adx_arrow_h1,adx_arrow_h4;
   
   //----- Assign colors   
   adx_color_m1 = assigncolor(adx_m1,ADX_trend_level,di_p_m1, di_m_m1);
   adx_color_m5 = assigncolor(adx_m5,ADX_trend_level,di_p_m5, di_m_m5);
   adx_color_m15 = assigncolor(adx_m15,ADX_trend_level,di_p_m15, di_m_m15);
   adx_color_m30 = assigncolor(adx_m30,ADX_trend_level,di_p_m30, di_m_m30);
   adx_color_h1 = assigncolor(adx_h1,ADX_trend_level,di_p_h1, di_m_h1);
   adx_color_h4 = assigncolor(adx_h4,ADX_trend_level,di_p_h4, di_m_h4);
   
   cci_color_entry_m1 = assignCCIcolor (cci_entry_m1);
   cci_color_entry_m5 = assignCCIcolor (cci_entry_m5);
   cci_color_entry_m15 = assignCCIcolor (cci_entry_m15);
   cci_color_entry_m30 = assignCCIcolor (cci_entry_m30);
   cci_color_entry_h1 = assignCCIcolor (cci_entry_h1);
   cci_color_entry_h4 = assignCCIcolor (cci_entry_h4);
   
   cci_color_trend_m1 = assignCCIcolor (cci_trend_m1);
   cci_color_trend_m5 = assignCCIcolor (cci_trend_m5);
   cci_color_trend_m15 = assignCCIcolor (cci_trend_m15);
   cci_color_trend_m30 = assignCCIcolor (cci_trend_m30);
   cci_color_trend_h1 = assignCCIcolor (cci_trend_h1);
   cci_color_trend_h4 = assignCCIcolor (cci_trend_h4);
   
   //---- feed all the ADX values into strings      
   string adx_value_m1 = adx_m1;
   string adx_value_m5 = adx_m5;
   string adx_value_m15 = adx_m15;
   string adx_value_m30 = adx_m30;
   string adx_value_h1 = adx_h1;
   string adx_value_h4 = adx_h4;
   
   //---- feed all the CCI values into strings 
   string cci_value_entry_m1 = cci_entry_m1;
   string cci_value_trend_m1 = cci_trend_m1;
   string cci_value_e1ago_m1 = cci_entry_1ago_m1;
   string cci_value_t1ago_m1 = cci_entry_1ago_m1;
   string cci_value_entry_m5 = cci_entry_m5;
   string cci_value_trend_m5 = cci_trend_m5;
   string cci_value_e1ago_m5 = cci_entry_1ago_m5;
   string cci_value_t1ago_m5 = cci_entry_1ago_m5;
   string cci_value_entry_m15 = cci_entry_m15;
   string cci_value_trend_m15 = cci_trend_m15;
   string cci_value_e1ago_m15 = cci_entry_1ago_m15;
   string cci_value_t1ago_m15 = cci_entry_1ago_m15;
   string cci_value_entry_m30 = cci_entry_m30;
   string cci_value_trend_m30 = cci_trend_m30;
   string cci_value_e1ago_m30 = cci_entry_1ago_m30;
   string cci_value_t1ago_m30 = cci_entry_1ago_m30;
   string cci_value_entry_h1 = cci_entry_h1;
   string cci_value_trend_h1 = cci_trend_h1;
   string cci_value_e1ago_h1 = cci_entry_1ago_h1;
   string cci_value_t1ago_h1 = cci_entry_1ago_h1;
   string cci_value_entry_h4 = cci_entry_h4;
   string cci_value_trend_h4 = cci_trend_h4;
   string cci_value_e1ago_h4 = cci_entry_1ago_h4;
   string cci_value_t1ago_h4 = cci_entry_1ago_h4;
      
   //----- Assign Arrows
   adx_arrow_m1 = AssignArrow(adx_m1,di_p_m1,di_m_m1);
   adx_arrow_m5 = AssignArrow(adx_m5,di_p_m5,di_m_m5);
   adx_arrow_m15= AssignArrow(adx_m15,di_p_m15,di_m_m15);
   adx_arrow_m30= AssignArrow(adx_m30,di_p_m30,di_m_m30);
   adx_arrow_h1 = AssignArrow(adx_h1,di_p_h1,di_m_h1);
   adx_arrow_h4 = AssignArrow(adx_h4,di_p_h4,di_m_h4);

   //---- Entry: label
   ObjectCreate("ToR120-cci1",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci1","Entry:", 8, "Arial Bold", LightSteelBlue);
   ObjectSet("ToR120-cci1", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci1", OBJPROP_XDISTANCE, 62);
   ObjectSet("ToR120-cci1", OBJPROP_YDISTANCE, 30);
   //---- Trend: label
   ObjectCreate("ToR120-cci3",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci3","Trend:", 8, "Arial Bold", LightSteelBlue);
   ObjectSet("ToR120-cci3", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci3", OBJPROP_XDISTANCE, 60);
   ObjectSet("ToR120-cci3", OBJPROP_YDISTANCE, 45);
//+------------------------------------------------------------------+
//|  5 min                                                           |
//+------------------------------------------------------------------+
   ObjectCreate("ToR120-5",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-5","5 min:", 8, "Arial Bold", LightSteelBlue);
   ObjectSet("ToR120-5", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-5", OBJPROP_XDISTANCE, 60);
   ObjectSet("ToR120-5", OBJPROP_YDISTANCE, 2);
   //---- create 5 min value
   ObjectCreate("ToR120-6",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-6", " ADX "+StringSubstr(adx_value_m5,0,5)+" ",8, "Arial Bold",adx_color_m5);
   ObjectSet("ToR120-6", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-6", OBJPROP_XDISTANCE, 90);
   ObjectSet("ToR120-6", OBJPROP_YDISTANCE, 2);
   //---- create 5 min arrow, squiggle if ranging
   ObjectCreate("ToR120-6a",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-6a",adx_arrow_m5, 8, "Wingdings",adx_color_m5);
   ObjectSet("ToR120-6a", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-6a", OBJPROP_XDISTANCE, 150);
   ObjectSet("ToR120-6a", OBJPROP_YDISTANCE, 2); 
       
   //----create 5 min Strong/Weaker/Ranging
   ObjectCreate("ToR120-6d",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-6d", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-6d", OBJPROP_XDISTANCE, 90);
   ObjectSet("ToR120-6d", OBJPROP_YDISTANCE, 15);
   if (adx_m5 < ADX_trend_level)
      {
      ObjectSetText("ToR120-6d", " Ranging ",8, "Arial Bold",Gray);
      }
   else if (adx_m5 > adx_1ago_m5)
      {
      ObjectSetText("ToR120-6d", " Stronger ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-6d", " Weaker ",8, "Arial Bold",Maroon);
      }
   //---- CCI stuff ---- :)~~~
   //---- create 5 min cci entry value
   ObjectCreate("ToR120-cci6",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci6", " CCI(" + M5_EntryCCI_Period + ") "+StringSubstr(cci_value_entry_m5,0,6)+" ",8, "Arial Bold",cci_color_entry_m5);
   ObjectSet("ToR120-cci6", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci6", OBJPROP_XDISTANCE, 90);
   ObjectSet("ToR120-cci6", OBJPROP_YDISTANCE, 30);
   //---- create 5 min entry CCI direction
   ObjectCreate("ToR120-cci5b",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci5b", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci5b", OBJPROP_XDISTANCE, 165);
   ObjectSet("ToR120-cci5b", OBJPROP_YDISTANCE, 30);
   if (cci_entry_m5 > cci_entry_1ago_m5)
      {
      ObjectSetText("ToR120-cci5b", " Up ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-cci5b", " Down ",8, "Arial Bold",Maroon);
      }         
   //---- creat 5 min cci trend value
   ObjectCreate("ToR120-cci8",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci8", " CCI(" + M5_TrendCCI_Period + ") "+StringSubstr(cci_value_trend_m5,0,6)+" ",8, "Arial Bold",cci_color_trend_m5);
   ObjectSet("ToR120-cci8", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci8", OBJPROP_XDISTANCE, 90);
   ObjectSet("ToR120-cci8", OBJPROP_YDISTANCE, 45);
   //---- create 5 min trend CCI direction
   ObjectCreate("ToR120-cci5c",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci5c", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci5c", OBJPROP_XDISTANCE, 165);
   ObjectSet("ToR120-cci5c", OBJPROP_YDISTANCE, 45);
   if (cci_trend_m5 > cci_trend_1ago_m5)
      {
      ObjectSetText("ToR120-cci5c", " Up ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-cci5c", " Down ",8, "Arial Bold",Maroon);
      }
//+------------------------------------------------------------------+
//|  15 MIN                                                          |
//+------------------------------------------------------------------+
   ObjectCreate("ToR120-7",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-7","15 min:", 8, "Arial Bold", LightSteelBlue);
   ObjectSet("ToR120-7", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-7", OBJPROP_XDISTANCE, 180);
   ObjectSet("ToR120-7", OBJPROP_YDISTANCE, 2);
   //---- create 15 min value
   ObjectCreate("ToR120-8",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-8", " ADX "+StringSubstr(adx_value_m15,0,5)+" ",8, "Arial Bold",adx_color_m15);
   ObjectSet("ToR120-8", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-8", OBJPROP_XDISTANCE, 215);
   ObjectSet("ToR120-8", OBJPROP_YDISTANCE, 2);
   //---- create 15 min arrow, squiggle if ranging
   ObjectCreate("ToR120-8a",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-8a",adx_arrow_m15, 8, "Wingdings",adx_color_m15);
   ObjectSet("ToR120-8a", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-8a", OBJPROP_XDISTANCE, 270);
   ObjectSet("ToR120-8a", OBJPROP_YDISTANCE, 2); 
   //----create 15 min Strong/Weaker/Ranging
   ObjectCreate("ToR120-8d",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-8d", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-8d", OBJPROP_XDISTANCE, 210);
   ObjectSet("ToR120-8d", OBJPROP_YDISTANCE, 15);
   if (adx_m15 < ADX_trend_level)
      {
      ObjectSetText("ToR120-8d", " Ranging ",8, "Arial Bold",Gray);
      }
   else if (adx_m15 > adx_1ago_m15)
      {
      ObjectSetText("ToR120-8d", " Stronger ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-8d", " Weaker ",8, "Arial Bold",Maroon);
      }
   //---- CCI stuff ---- :)~~~
   //---- create 15 min cci entry value
   ObjectCreate("ToR120-cci10",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci10", " CCI(" + M15_EntryCCI_Period + ") "+StringSubstr(cci_value_entry_m15,0,6)+" ",8, "Arial Bold",cci_color_entry_m15);
   ObjectSet("ToR120-cci10", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci10", OBJPROP_XDISTANCE, 210);
   ObjectSet("ToR120-cci10", OBJPROP_YDISTANCE, 30);
   //---- create 15 min entry CCI direction
   ObjectCreate("ToR120-cci9b",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci9b", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci9b", OBJPROP_XDISTANCE, 280);
   ObjectSet("ToR120-cci9b", OBJPROP_YDISTANCE, 30);
   if (cci_entry_m15 > cci_entry_1ago_m15)
      {
      ObjectSetText("ToR120-cci9b", " Up ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-cci9b", " Down ",8, "Arial Bold",Maroon);
      }
   //---- create 15 min cci trend value
   ObjectCreate("ToR120-cci12",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci12", " CCI(" + M15_TrendCCI_Period + ") "+StringSubstr(cci_value_trend_m15,0,6)+" ", 8, "Arial Bold",cci_color_trend_m15);
   ObjectSet("ToR120-cci12", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci12", OBJPROP_XDISTANCE, 210);
   ObjectSet("ToR120-cci12", OBJPROP_YDISTANCE, 45);
   //---- create 15 min trend CCI direction
   ObjectCreate("ToR120-cci9c",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSet("ToR120-cci9c", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-cci9c", OBJPROP_XDISTANCE, 280);
     ObjectSet("ToR120-cci9c", OBJPROP_YDISTANCE, 45);
     if (cci_trend_m15 > cci_trend_1ago_m15)
        {
        ObjectSetText("ToR120-cci9c", " Up ",8, "Arial Bold",Green);
        }
     else 
        {
        ObjectSetText("ToR120-cci9c", " Down ",8, "Arial Bold",Maroon);
        }      
//+------------------------------------------------------------------+
//|  30 MIN                                                          |
//+------------------------------------------------------------------+
   ObjectCreate("ToR120-9",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-9","30 min:", 8, "Arial Bold", LightSteelBlue);
     ObjectSet("ToR120-9", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-9", OBJPROP_XDISTANCE, 300);
     ObjectSet("ToR120-9", OBJPROP_YDISTANCE, 2);
   //---- create 30 min value
   ObjectCreate("ToR120-10",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-10", " ADX "+StringSubstr(adx_value_m30,0,5)+" ",8, "Arial Bold",adx_color_m30);
     ObjectSet("ToR120-10", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-10", OBJPROP_XDISTANCE, 335);
     ObjectSet("ToR120-10", OBJPROP_YDISTANCE, 2);
   //---- create 30 min arrow, squiggle if ranging
   ObjectCreate("ToR120-10a",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-10a",adx_arrow_m30,8, "Wingdings",adx_color_m30);
     ObjectSet("ToR120-10a", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-10a", OBJPROP_XDISTANCE, 395);
     ObjectSet("ToR120-10a", OBJPROP_YDISTANCE, 2); 
   
   //----create 30 min Strong/Weaker/Ranging
   ObjectCreate("ToR120-10d",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-10d", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-10d", OBJPROP_XDISTANCE, 335);
   ObjectSet("ToR120-10d", OBJPROP_YDISTANCE, 15);
   if (adx_m30 < ADX_trend_level)
      {
      ObjectSetText("ToR120-10d", " Ranging ",8, "Arial Bold",Gray);
      }
   else if (adx_m30 > adx_1ago_m30)
      {
      ObjectSetText("ToR120-10d", " Stronger ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-10d", " Weaker ",8, "Arial Bold",Maroon);
      }
   //---- CCI stuff ---- :)~~~
   //---- create 30 min cci entry value
   ObjectCreate("ToR120-cci32e",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci32e", " CCI(" + M30_EntryCCI_Period + ") "+StringSubstr(cci_value_entry_m30,0,6)+" ",8, "Arial Bold",cci_color_entry_m30);
   ObjectSet("ToR120-cci32e", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci32e", OBJPROP_XDISTANCE, 335);
   ObjectSet("ToR120-cci32e", OBJPROP_YDISTANCE, 30);
   //---- create 1 min entry CCI direction
   ObjectCreate("ToR120-cci33e",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci33e", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci33e", OBJPROP_XDISTANCE, 410);
   ObjectSet("ToR120-cci33e", OBJPROP_YDISTANCE, 30);
   if (cci_entry_m30 > cci_entry_1ago_m30)
     {
     ObjectSetText("ToR120-cci33e", " Up ",8, "Arial Bold",Green);
     }
   else 
     {
     ObjectSetText("ToR120-cci33e", " Down ",8, "Arial Bold",Maroon);
     }
   //---- creat 30 min cci trend value
   ObjectCreate("ToR120-cci32t",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci32t", " CCI(" + M30_TrendCCI_Period + ") "+StringSubstr(cci_value_trend_m30,0,6)+" ",8, "Arial Bold",cci_color_trend_m30);
   ObjectSet("ToR120-cci32t", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci32t", OBJPROP_XDISTANCE, 335);
   ObjectSet("ToR120-cci32t", OBJPROP_YDISTANCE, 45);
   //---- create 30 min trend cci direction
   ObjectCreate("ToR120-cci33t",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci33t", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci33t", OBJPROP_XDISTANCE, 410);
   ObjectSet("ToR120-cci33t", OBJPROP_YDISTANCE, 45);
   if (cci_trend_m30 > cci_trend_1ago_m30)
     {
     ObjectSetText("ToR120-cci33t", " Up ",8, "Arial Bold",Green);
     }
   else 
     {
     ObjectSetText("ToR120-cci33t", " Down ",8, "Arial Bold",Maroon);
     }
//+------------------------------------------------------------------+
//|  1 HOUR                                                          |
//+------------------------------------------------------------------+
   ObjectCreate("ToR120-11",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-11","1 hr:", 8, "Arial Bold", LightSteelBlue);
     ObjectSet("ToR120-11", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-11", OBJPROP_XDISTANCE, 430);
     ObjectSet("ToR120-11", OBJPROP_YDISTANCE, 2);
   //---- create 15 min value
   ObjectCreate("ToR120-12",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-12", " ADX "+StringSubstr(adx_value_h1,0,5)+" ",8, "Arial Bold",adx_color_h1);
     ObjectSet("ToR120-12", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-12", OBJPROP_XDISTANCE, 465);
     ObjectSet("ToR120-12", OBJPROP_YDISTANCE, 2);
   ObjectCreate("ToR120-12a",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-12a",adx_arrow_h1, 8, "Wingdings",adx_color_h1);
     ObjectSet("ToR120-12a", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-12a", OBJPROP_XDISTANCE, 525);
     ObjectSet("ToR120-12a", OBJPROP_YDISTANCE, 2);
   //----create hour min Strong/Weaker/Ranging
   ObjectCreate("ToR120-12d",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-12d", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-12d", OBJPROP_XDISTANCE, 465);
   ObjectSet("ToR120-12d", OBJPROP_YDISTANCE, 15);
   if (adx_h1 < ADX_trend_level)
      {
      ObjectSetText("ToR120-12d", " Ranging ",8, "Arial Bold",Gray);
      }
   else if (adx_h1 > adx_1ago_h1)
      {
      ObjectSetText("ToR120-12d", " Stronger ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-12d", " Weaker ",8, "Arial Bold",Maroon);
      }
   //---- CCI stuff ---- :)~~~
   //---- create 60 min cci entry value
   ObjectCreate("ToR120-cci62e",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci62e", " CCI(" + H1_EntryCCI_Period + ") "+StringSubstr(cci_value_entry_h1,0,6)+" ",8, "Arial Bold",cci_color_entry_h1);
   ObjectSet("ToR120-cci62e", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci62e", OBJPROP_XDISTANCE, 465);
   ObjectSet("ToR120-cci62e", OBJPROP_YDISTANCE, 30);
   //---- create 60 min entry CCI direction
   ObjectCreate("ToR120-cci63e",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci63e", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci63e", OBJPROP_XDISTANCE, 540);
   ObjectSet("ToR120-cci63e", OBJPROP_YDISTANCE, 30);
   if (cci_entry_h1 > cci_entry_1ago_h1)
     {
     ObjectSetText("ToR120-cci63e", " Up ",8, "Arial Bold",Green);
     }
   else 
     {
     ObjectSetText("ToR120-cci63e", " Down ",8, "Arial Bold",Maroon);
     }
   //---- creat 60 min cci trend value
   ObjectCreate("ToR120-cci62t",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci62t", " CCI(" + H1_TrendCCI_Period + ") "+StringSubstr(cci_value_trend_h1,0,6)+" ",8, "Arial Bold",cci_color_trend_h1);
   ObjectSet("ToR120-cci62t", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci62t", OBJPROP_XDISTANCE, 465);
   ObjectSet("ToR120-cci62t", OBJPROP_YDISTANCE, 45);
   //---- create 60 min trend cci direction
   ObjectCreate("ToR120-cci63t",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci63t", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci63t", OBJPROP_XDISTANCE, 540);
   ObjectSet("ToR120-cci63t", OBJPROP_YDISTANCE, 45);
   if (cci_trend_h1 > cci_trend_1ago_h1)
     {
     ObjectSetText("ToR120-cci63t", " Up ",8, "Arial Bold",Green);
     }
   else 
     {
     ObjectSetText("ToR120-cci63t", " Down ",8, "Arial Bold",Maroon);
     }
//+------------------------------------------------------------------+
//|  4 HOUR                                                          |
//+------------------------------------------------------------------+
   ObjectCreate("ToR120-13",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-13","4 hr:", 8, "Arial Bold", LightSteelBlue);
     ObjectSet("ToR120-13", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-13", OBJPROP_XDISTANCE, 570);
     ObjectSet("ToR120-13", OBJPROP_YDISTANCE, 2);
   //---- create 15 min value
   ObjectCreate("ToR120-14",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-14", " ADX "+StringSubstr(adx_value_h4,0,5)+" ",8, "Arial Bold",adx_color_h4);
     ObjectSet("ToR120-14", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-14", OBJPROP_XDISTANCE, 595);
     ObjectSet("ToR120-14", OBJPROP_YDISTANCE, 2);
   ObjectCreate("ToR120-15",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
     ObjectSetText("ToR120-15",adx_arrow_h4,8, "Wingdings",adx_color_h4);
     ObjectSet("ToR120-15", OBJPROP_CORNER, 0);
     ObjectSet("ToR120-15", OBJPROP_XDISTANCE, 655);
     ObjectSet("ToR120-15", OBJPROP_YDISTANCE, 2);
   
   //----create 4hour min Strong/Weaker/Ranging
   ObjectCreate("ToR120-18d",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-18d", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-18d", OBJPROP_XDISTANCE, 595);
   ObjectSet("ToR120-18d", OBJPROP_YDISTANCE, 15);
   if (adx_h4 < ADX_trend_level)
      {
      ObjectSetText("ToR120-18d", " Ranging ",8, "Arial Bold",Gray);
      }
   else if (adx_h4 > adx_1ago_h4)
      {
      ObjectSetText("ToR120-18d", " Stronger ",8, "Arial Bold",Green);
      }
   else 
      {
      ObjectSetText("ToR120-18d", " Weaker ",8, "Arial Bold",Maroon);
      }
   //---- CCI stuff ---- :)~~~
   //---- create 240 min cci entry value
   ObjectCreate("ToR120-cci240e",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci240e", " CCI(" + H4_EntryCCI_Period + ") "+StringSubstr(cci_value_entry_h4,0,6)+" ",8, "Arial Bold",cci_color_entry_h4);
   ObjectSet("ToR120-cci240e", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci240e", OBJPROP_XDISTANCE, 595);
   ObjectSet("ToR120-cci240e", OBJPROP_YDISTANCE, 30);
   //---- create 240 min entry CCI direction
   ObjectCreate("ToR120-cci241e",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci241e", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci241e", OBJPROP_XDISTANCE, 665);
   ObjectSet("ToR120-cci241e", OBJPROP_YDISTANCE, 30);
   if (cci_entry_h4 > cci_entry_1ago_h4)
     {
     ObjectSetText("ToR120-cci241e", " Up ",8, "Arial Bold",Green);
     }
   else 
     {
     ObjectSetText("ToR120-cci241e", " Down ",8, "Arial Bold",Maroon);
     }
   //---- creat 240 min cci trend value
   ObjectCreate("ToR120-cci240t",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSetText("ToR120-cci240t", " CCI(" + H4_TrendCCI_Period + ") "+StringSubstr(cci_value_trend_h4,0,6)+" ",8, "Arial Bold",cci_color_trend_h4);
   ObjectSet("ToR120-cci240t", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci240t", OBJPROP_XDISTANCE, 595);
   ObjectSet("ToR120-cci240t", OBJPROP_YDISTANCE, 45);
   //---- create 240 min trend cci direction
   ObjectCreate("ToR120-cci241t",OBJ_LABEL, WindowFind("ToR 1.23 "), 0, 0);
   ObjectSet("ToR120-cci241t", OBJPROP_CORNER, 0);
   ObjectSet("ToR120-cci241t", OBJPROP_XDISTANCE, 665);
   ObjectSet("ToR120-cci241t", OBJPROP_YDISTANCE, 45);
   if (cci_trend_h4 > cci_trend_1ago_h4)
     {
     ObjectSetText("ToR120-cci241t", " Up ",8, "Arial Bold",Green);
     }
   else 
     {
     ObjectSetText("ToR120-cci241t", " Down ",8, "Arial Bold",Maroon);
     }

   return(0);
  } //---- end of main loop
   
//+------------------------------------------------------------------+
//|  Common Functions                                                |
//+------------------------------------------------------------------+
   color assigncolor(double adx_time,double ADX_trend_level,double di_p_time,double di_m_time)
      {
      if (adx_time < ADX_trend_level) { return (LightSkyBlue); }
      else if (di_p_time > di_m_time) { return (Lime); }
      else {return (Red); }
      }
   color assignCCIcolor(double cci_time)
      {
      if (cci_time > 0) { return (Lime); }
      else {return (Red); }                            
      }
   string AssignArrow (double adx_time, double di_p_time, double di_m_time)
      {                                
      if ((adx_time < ADX_trend_level) && (adx_time != 0)) 
         {
         return ("h");
         }
      else if (adx_time < ADX_trend_strong )
         {
         if (di_p_time > di_m_time)
            {
            return ("ì");
            }  
         else
            {
            return ("î");
            }
         }
      else 
         {
         if (di_p_time > di_m_time)
            {
            return ("é");
            }
         else
            {
            return ("ê");
            }
         }
      } //End Function





Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:

Movement directional index
Commodity channel index


Custom Indicators Used:

Order Management characteristics:

Other Features: