problem in showing New York time

 

hi

I use TimeZone indicator ( attached)

it shows all time correctly but when I put Time Minute for New York it didn't change color to Lime

source code is :

 if (TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) < 17 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) > 0 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) < 6 )
    ObjectSetText("Dollar", InfoUSD, FontSize, Font, FontColorMarketOpen);


it worked correctly but when I add below code it didn't work:

&& TimeMinute(TimeLocal()+((0-timezone)*3600))<00

 if (TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) < 17 && TimeMinute(TimeLocal()+((0-timezone)*3600))<00 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) > 0 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) < 6 )
    ObjectSetText("Dollar", InfoUSD, FontSize, Font, FontColorMarketOpen);

other times worked correctly...

where is problem?

Best Regards

Neda

Files:
TimeZone.mq4  14 kb
 
Neda shahbazi:

hi

I use TimeZone indicator ( attached)

it shows all time correctly but when I put Time Minute for New York it didn't change color to Lime

source code is :


it worked correctly but when I add below code it didn't work:

&& TimeMinute(TimeLocal()+((0-timezone)*3600))<00

other times worked correctly...

where is problem?

Best Regards

Neda

the main reason why your code does not perform well is because there is conflict within your code  .  I did some changing with your code , hope this fix your problem . 

//+------------------------------------------------------------------+
//|                                           Arif Endro Nugroho.mq4 |
//|      Copyright © 2009, Arif Endro Nugroho <arif_endro@yahoo.com> |
//|                                         http://www.vectra.web.id |
//|  Last updated: 2009.09.10 19:30 GMT+7                            |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Arif E. Nugroho <arif_endro@yahoo.com>"
#property link      "http://www.vectra.web.id"

#property indicator_chart_window
//---- input parameters
extern int       corner=1;
extern int       xdis=20;
extern int       ydis=20;
extern string    Font="Lucida Console";
extern int       FontSize=9;
extern color     FontColor=C'188,188,188';
extern color     FontColorMarketOpen=clrLime;
extern double       timezone=3.5;
extern bool      back=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   ObjectDelete("Home");
   ObjectCreate("Home", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Home", OBJPROP_BACK, back);
   ObjectSet("Home", OBJPROP_CORNER, corner);
   ObjectSet("Home", OBJPROP_XDISTANCE, xdis);
   ObjectSet("Home", OBJPROP_YDISTANCE, ydis);

   ObjectDelete("Dollar");
   ObjectCreate("Dollar", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Dollar", OBJPROP_BACK, back);
   ObjectSet("Dollar", OBJPROP_CORNER, corner);
   ObjectSet("Dollar", OBJPROP_XDISTANCE, xdis);
   ObjectSet("Dollar", OBJPROP_YDISTANCE, ydis + 10);

   ObjectDelete("Cable");
   ObjectCreate("Cable", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Cable", OBJPROP_BACK, back);
   ObjectSet("Cable", OBJPROP_CORNER, corner);
   ObjectSet("Cable", OBJPROP_XDISTANCE, xdis);
   ObjectSet("Cable", OBJPROP_YDISTANCE, ydis + 20);

   ObjectDelete("Yen");
   ObjectCreate("Yen", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Yen", OBJPROP_BACK, back);
   ObjectSet("Yen", OBJPROP_CORNER, corner);
   ObjectSet("Yen", OBJPROP_XDISTANCE, xdis);
   ObjectSet("Yen", OBJPROP_YDISTANCE, ydis + 30);

   ObjectDelete("Aussie");
   ObjectCreate("Aussie", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Aussie", OBJPROP_BACK, back);
   ObjectSet("Aussie", OBJPROP_CORNER, corner);
   ObjectSet("Aussie", OBJPROP_XDISTANCE, xdis);
   ObjectSet("Aussie", OBJPROP_YDISTANCE, ydis + 40);

   ObjectDelete("Server");
   ObjectCreate("Server", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Server", OBJPROP_BACK, back);
   ObjectSet("Server", OBJPROP_CORNER, corner);
   ObjectSet("Server", OBJPROP_XDISTANCE, xdis);
   ObjectSet("Server", OBJPROP_YDISTANCE, ydis + 50);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("Home");
   ObjectDelete("Cable");
   ObjectDelete("Dollar");
   ObjectDelete("Yen");
   ObjectDelete("Aussie");
   ObjectDelete("Server");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();

   color  FontColorDayPercentGain = Silver;
   color  FontColorWeekPercentGain = Silver;
   color  FontColorMonthPercentGain = Silver;

// New York = GMT-5, London = GMT+0, Tokyo = GMT+9, Sydney = GMT+10
   string InfoHome   = "Home.....: " + TimeToStr(TimeLocal(), TIME_SECONDS);
   string InfoUSD    = "New York.: " + TimeToStr(TimeLocal() + ((- 5 - timezone) * 3600), TIME_SECONDS);
   string InfoGBP    = "London...: " + TimeToStr(TimeLocal() + ((0 - timezone) * 3600), TIME_SECONDS);
   string InfoJPY    = "Tokyo....: " + TimeToStr(TimeLocal() + ((8 - timezone) * 3600), TIME_SECONDS);
   string InfoAUD    = "Sydney...: " + TimeToStr(TimeLocal() + ((9 - timezone) * 3600), TIME_SECONDS);
   string InfoServer = "Server...: " + TimeToStr(TimeCurrent(), TIME_SECONDS);

//----

// London local session...: 08.00 - 17.00
// New York local session.: 08.00 - 17.00
// Tokyo local session....: 09.00 - 18.00
// Sydney local session...: 08.00 - 17.00

   if(TimeHour(TimeLocal()) >= 8 && TimeHour(TimeLocal()) < 17 && TimeDayOfWeek(TimeLocal()) > 0 && TimeDayOfWeek(TimeLocal()) < 6)
      ObjectSetText("Home", InfoHome, FontSize, Font, FontColorMarketOpen);
   else
      ObjectSetText("Home", InfoHome, FontSize, Font, FontColor);

   if(TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) >= 8)
      if(TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) < 17)
                  ObjectSetText("Dollar", InfoUSD, FontSize, Font, FontColorMarketOpen);
               else
                  ObjectSetText("Dollar", InfoUSD, FontSize, Font, FontColor);

   if(TimeHour(TimeLocal() + ((0 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + ((0 - timezone) * 3600)) < 17)
      ObjectSetText("Cable", InfoGBP, FontSize, Font, FontColorMarketOpen);
   else
      ObjectSetText("Cable", InfoGBP, FontSize, Font, FontColor);

   if(TimeHour(TimeLocal() + ((8 - timezone) * 3600)) >= 9 && TimeHour(TimeLocal() + ((8 - timezone) * 3600)) < 18 )
      ObjectSetText("Yen", InfoJPY, FontSize, Font, FontColorMarketOpen);
   else
      ObjectSetText("Yen", InfoJPY, FontSize, Font, FontColor);

   if(TimeHour(TimeLocal() + ((9 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + ((9 - timezone) * 3600)) < 17 )
      ObjectSetText("Aussie", InfoAUD, FontSize, Font, FontColorMarketOpen);
   else
      ObjectSetText("Aussie", InfoAUD, FontSize, Font, FontColor);

   ObjectSetText("Server", InfoServer, FontSize, Font, FontColor);
//----

   Comment(TimeHour(TimeLocal()));
   return(0);
  }
//+------------------------------------------------------------------+  
//+------------------------------------------------------------------+
 
Cosmas Moses:

the main reason why your code does not perform well is because there is conflict within your code  .  I did some changing with your code , hope this fix your problem . 

hi thanks

but as I told codes worked correctly untill I add below code:

&& TimeMinute(TimeLocal()+((0-timezone)*3600))<00


you didn't use above code I changed code like below:

 if (TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) < 17 && TimeMinute(TimeLocal()+((0-timezone)*3600))<00 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) > 0 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) < 6 )
    ObjectSetText("Dollar", InfoUSD, FontSize, Font, FontColorMarketOpen);


I mean I need time in minute TimeMinute...

I add this code to other countries it worked correctly but it doesn't work for New York I don't know why this happen...

if (TimeHour(TimeLocal()) >= 8 && TimeHour(TimeLocal()) < 17 && TimeDayOfWeek(TimeLocal()) > 0 && TimeDayOfWeek(TimeLocal()) < 6 )
    ObjectSetText("Home"  , InfoHome, FontSize, Font, FontColorMarketOpen);
   else
    ObjectSetText("Home"  , InfoHome, FontSize, Font, FontColor);

   if (TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + ((- 5 - timezone) * 3600)) < 17 && TimeMinute(TimeLocal()+((0-timezone)*3600))<00 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) > 0 && TimeDayOfWeek(TimeLocal() + ((- 5 - timezone) * 3600)) < 6 )
    ObjectSetText("Dollar", InfoUSD, FontSize, Font, FontColorMarketOpen);
   else
    ObjectSetText("Dollar", InfoUSD, FontSize, Font, FontColor);

   if (TimeHour(TimeLocal() + ((  0 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + ((  0 - timezone) * 3600)) < 17 && TimeMinute(TimeLocal()+((0-timezone)*3600))<30 && TimeDayOfWeek(TimeLocal() + ((  0 - timezone) * 3600)) > 0 && TimeDayOfWeek(TimeLocal() + ((  0 - timezone) * 3600)) < 6 )
    ObjectSetText("Cable" , InfoGBP, FontSize, Font, FontColorMarketOpen);
   else
    ObjectSetText("Cable" , InfoGBP, FontSize, Font, FontColor);

   if (TimeHour(TimeLocal() + ((  8 - timezone) * 3600)) >= 9 && TimeHour(TimeLocal() + ((  8 - timezone) * 3600)) < 18 && TimeMinute(TimeLocal()+((0-timezone)*3600))<00 && TimeDayOfWeek(TimeLocal() + ((  8 - timezone) * 3600)) > 0 && TimeDayOfWeek(TimeLocal() + ((  8 - timezone) * 3600)) < 6 )
    ObjectSetText("Yen"   , InfoJPY, FontSize, Font, FontColorMarketOpen);
   else
    ObjectSetText("Yen"   , InfoJPY, FontSize, Font, FontColor);

   if (TimeHour(TimeLocal() + (( 9 - timezone) * 3600)) >= 8 && TimeHour(TimeLocal() + (( 9 - timezone) * 3600)) < 17 && TimeMinute(TimeLocal()+((0-timezone)*3600))<00 && TimeDayOfWeek(TimeLocal() + (( 9 - timezone) * 3600)) > 0 && TimeDayOfWeek(TimeLocal() + (( 9 - timezone) * 3600)) < 6 )
    ObjectSetText("Aussie", InfoAUD, FontSize, Font, FontColorMarketOpen);
   else
    ObjectSetText("Aussie", InfoAUD, FontSize, Font, FontColor);

    ObjectSetText("Server", InfoServer, FontSize, Font, FontColor);


see in above codes I use TimeMinute...

 
any body can't help me???????????????