Giving Back: Hour To Trade

 

This one allows you to give your user a choice on what hours to trade. Now it will be different based on the users broker server time, but I am sure you can work something out.

// Externs:

extern bool          Hour0 = true;
extern bool          Hour1 = true;
extern bool          Hour2 = true;
extern bool          Hour3 = true;
extern bool          Hour4 = true;
extern bool          Hour5 = true;
extern bool          Hour6 = true;
extern bool          Hour7 = true;
extern bool          Hour8 = true;
extern bool          Hour9 = true;
extern bool          Hour10 = true;
extern bool          Hour11 = true;
extern bool          Hour12 = true;
extern bool          Hour13 = true;
extern bool          Hour14 = true;
extern bool          Hour15 = true;
extern bool          Hour16 = true;
extern bool          Hour17 = true;
extern bool          Hour18 = true;
extern bool          Hour19 = true;
extern bool          Hour20 = true;
extern bool          Hour21 = true;
extern bool          Hour22 = true;
extern bool          Hour23 = true;

extern bool          EnableTimeStatusNotification = true;   // Turns on/off notification msg


// Init

   if (EnableTimeStatusNotification)
   {   
      if(!ObjectCreate("Obj_TimeStatusText", OBJ_LABEL, 0, 0, 0))
      {
         Print("error: can't create text_object! code #",GetLastError());
         return(0);
      }
   }


// Start

   if (!IsHourGood(Hour0, Hour1, Hour2, Hour3, Hour4, Hour5, Hour6, Hour7, Hour8, Hour9, Hour10, Hour11, Hour12, Hour13, Hour14, Hour15, Hour16, Hour17, Hour18, Hour19, Hour20, Hour21, Hour22, Hour23))
   {
      if (EnableTimeStatusNotification)
      {
         strTimeStatus = "Time Status: Waiting";
         ObjectSet("Obj_TimeStatusText", OBJPROP_CORNER, 2);
         ObjectSet("Obj_TimeStatusTextt", OBJPROP_XDISTANCE, XTimeStatus);
         ObjectSet("Obj_TimeStatusText", OBJPROP_YDISTANCE, YTimeStatus);
         ObjectSetText("Obj_TimeStatusText", strTimeStatus, 12, "Arial", Orange);         
      }
      
      return(0);
   }
   else
   {
      if (EnableTimeStatusNotification)
      {
         strTimeStatus = "Time Status: Active";
         ObjectSet("Obj_TimeStatusText", OBJPROP_CORNER, 2);
         ObjectSet("Obj_TimeStatusTextt", OBJPROP_XDISTANCE, XTimeStatus);
         ObjectSet("Obj_TimeStatusText", OBJPROP_YDISTANCE, YTimeStatus);
         ObjectSetText("Obj_TimeStatusText", strTimeStatus, 12, "Arial", LawnGreen);         
      }   
   } 

// Functions:
//+------------------------------------------------------------------+
//| IsHourGood                                                       |
//+------------------------------------------------------------------+
bool IsHourGood(bool Hour0, bool Hour1, bool Hour2, bool Hour3, bool Hour4, bool Hour5, bool Hour6, bool Hour7, bool Hour8, bool Hour9, bool Hour10, bool Hour11, bool Hour12, bool Hour13, bool Hour14, bool Hour15, bool Hour16, bool Hour17, bool Hour18, bool Hour19, bool Hour20, bool Hour21, bool Hour22, bool Hour23)
{
   int CurrHour = 00;
   bool IsGood = false;
   
   CurrHour = TimeHour(TimeCurrent());
   
   if (Hour0 == true && CurrHour == 00)
   {
      IsGood = true;
   }
   if (Hour1 == true && CurrHour == 01)
   {
      IsGood = true;
   }   
   if (Hour2 == true && CurrHour == 02)
   {
      IsGood = true;
   }
   if (Hour3 == true && CurrHour == 03)
   {
      IsGood = true;
   }
   if (Hour4 == true && CurrHour == 04)
   {
      IsGood = true;
   }
   if (Hour5 == true && CurrHour == 05)
   {
      IsGood = true;
   }   
   if (Hour6 == true && CurrHour == 06)
   {
      IsGood = true;
   }
   if (Hour7 == true && CurrHour == 07)
   {
      IsGood = true;
   }  
   if (Hour8 == true && CurrHour == 08)
   {
      IsGood = true;
   }
   if (Hour9 == true && CurrHour == 09)
   {
      IsGood = true;
   }   
   if (Hour10 == true && CurrHour == 10)
   {
      IsGood = true;
   }
   if (Hour11 == true && CurrHour == 11)
   {
      IsGood = true;
   }
   if (Hour12 == true && CurrHour == 12)
   {
      IsGood = true;
   }
   if (Hour13 == true && CurrHour == 13)
   {
      IsGood = true;
   }   
   if (Hour14 == true && CurrHour == 14)
   {
      IsGood = true;
   }
   if (Hour15 == true && CurrHour == 15)
   {
      IsGood = true;
   }    
   if (Hour16 == true && CurrHour == 16)
   {
      IsGood = true;
   }
   if (Hour17 == true && CurrHour == 17)
   {
      IsGood = true;
   }   
   if (Hour18 == true && CurrHour == 18)
   {
      IsGood = true;
   }
   if (Hour19 == true && CurrHour == 19)
   {
      IsGood = true;
   }
   if (Hour20 == true && CurrHour == 20)
   {
      IsGood = true;
   }
   if (Hour21 == true && CurrHour == 21)
   {
      IsGood = true;
   }   
   if (Hour22 == true && CurrHour == 22)
   {
      IsGood = true;
   }
   if (Hour23 == true && CurrHour == 23)
   {
      IsGood = true;
   }     
  
   return (IsGood);
}
//+------------------------------------------------------------------+